I feel like this question has been asked before, but I couldn't find it.
I know that if you are engaged in combat with someone (or at least in melee range of someone's weapon, 5 feet normally or 10 with polearms) and you move away willingly on your turn, your opponent can make an opportunity attack. I am also aware that if you are engaged in melee combat with a target, you can sidestep around them without them being able to make an opportunity attack if you stay within 5 feet (or 10 for polearms).
What I want to know is, on your turn if you start OUT of the melee range, then enter the melee range (whether by passing or attacking), and then leave the melee range, can your opponent then make an opportunity attack? More specifically for movement purposes.
So if a monk runs past a bandit when he previously wasn't in Melee range before, can the bandit make the attack? Or does he have to start his turn in Melee range and then move?
Best Answer
Yes
A creature does provoke an opportunity attack when it moves into melee range and then back out on the same turn.
The described scenario is exactly the reason why OAs were introduced — without them, hit-and-run tactics were superior for melee combatants.
There are few ways not to provoke an OA when moving out of somebody's reach:
See Player's Handbook, page 195:
As @V2Blast pointed out in a comment, keep in mind that you have to expend your Reaction in order to make an opportunity attack, and you have only one Reaction until the start of your next turn. Basically you can make no more than one OA per round. The same applies for your enemies, unless they have a specific feature.
In addition, @PJRZ pointed out that there are features that change the action economy for the Disengage action. For example, the Goblin's Nimble Escape trait (which both the monster and the playable race have) allows it to use a Bonus Action to Disengage rather than an Action. (Rogues' 2nd-level Cunning Action feature allows them to do the same.) In addition, the Owl's Flyby feature means that it does not provoke opportunity attacks at all when flying out of an enemy's reach.