[RPG] Does casting Lightning Bolt in melee provoke an Opportunity Attack?

dnd-5eopportunity-attackspells

Our Sorcerer wanted to cast a Lightning Bolt as their attack on a monster that had made it into melee with that Sorcerer.
DM said could make the attack, but it would provoke an OA (that would likely kill the sorcerer).

Player argued that as a magic-using character they would be as adept as a Fighter doing a melee attack. The range being Self was integral to the issue. What lies beyond the initial target was not in question. AoE was not relevant.

DM ruled (and yes, whatever he decides is what we go with, I'm here looking for discussion of rules and logic of the situation), that it took enough time summoning the magic that the monster would get a free shot. Player countered that a successful attack would stop the spell anyway.

Player maintained that it was essentially a melee attack he was making as the range was less than 5 feet (starting with the caster) and should not provoke OA.

Which position is correct though? Does casting Lightning Bolt within an enemy's reach provoke an Opportunity Attack?

@Rubiksmoose This question is different enough from your provided generic answered question. Those who are versed in earlier version rules will benefit from the specifics of this question. As well as the specific differentiation between ranged attacks and the lightning bolt characteristics.

Best Answer

Casting spells never provokes an opportunity attack in D&D 5e. See the rules for Opportunity Attacks on the SRD:

Opportunity Attacks

In a fight, everyone is constantly watching for a chance to strike an enemy who is fleeing or passing by. Such a strike is called an opportunity attack.

You can make an opportunity attack when a hostile creature that you can see moves out of your reach. To make the opportunity attack, you use your reaction to make one melee attack against the provoking creature. The attack occurs right before the creature leaves your reach.

You can avoid provoking an opportunity attack by taking the Disengage action. You also don’t provoke an opportunity attack when you teleport or when someone or something moves you without using your movement, action, or reaction. For example, you don’t provoke an opportunity attack if an explosion hurls you out of a foe’s reach or if gravity causes you to fall past an enemy.

That bolded part is the only thing that grants an opportunity attack, and it requires you to move out of reach of an opponent. This makes them work very differently from previous versions. You can freely engage with an enemy through large threat ranges, and move around inside someone's threatened space, as long as you don't leave it.

Spell never provoke, and neither do ranged attacks. You do have Disadvantage on any attack rolls made with ranged attacks and ranged spells while in melee, but that only matters for spells that make any. Lightning Bolt isn't one of them.