As the title says. Is there a way for a character to leave melee combat without causing opportunity attacks? Do they have to make an athletics or acrobatics check to do so?
Disengage, as has been given in other answers,does allow you to use your action to move away without provoking an opportunity attack.
If you take the Disengage action, your movement doesn't provoke opportunity attacks for the rest of the turn.
Disengage just happens, no rolls on athletics to see if it is successful.
Rogue's Cunning Action
Rogues starting at the 2nd level can disengage as a bonus action. (Mentioned in Jamie Brace's answer.)
PHB p. 96
Monk's Step of the Wind
Starting at the second level may disengage as a bonus action by spending a Ki point. (As Christopher mentioned in the comments on Jamie Brace's answer)
One of the abilities gain from taking the mobility feat is when you attack a creature, you can move away from it without it being able to take an opportunity attack:
When you make a melee attack against a creature, you don't provoke opportunity attacks from that creature for the rest of the turn, whether you hit or not.
PHB p.168 (Thanks – Tijnkwan)
Using the Attack action, you can make a special melee attack to shove a creature, either to knock it prone or push it away from you. If you're able to make multiple attacks with the Attack action, this attack replaces one of them.
Since Opportunity Attack reads:
You can make an opportunity attack when a hostile creature that you can see moves out of your reach.
Since he is the creature moving out of reach, he can't take an opportunity attack, and you can use your extra attack action.
This can only be done if the target is no more than one size larger than you, and has to be within your reach. Also, this does require an Athletics roll contested by their Acrobatics roll.
Spells or Features
Spells or features that allow you to "push up to X feet away" or make the enemy flee. Each spell will have different attack rolls, or saving throws, depending on the spell.
There are a number of other ways to force an opponent to move, like:
- Gust of wind
- Eldritch blast (with repelling blast Invocation)
- Thunderous smite
- Grasping Vine
- Control Water (whirlpool option, if the enemy is standing in water)
Likewise, if a creature gains the Frightened condition, the enemy can't willingly move any closer to you. Moreover, a number of spells that impart fear have clauses that force the enemy to expend their movement trying to get away from you.
The creature can't willingly move closer to the source of its fear (PHB p.290)
Spells that contain this language include:
- Eyebite (Panicked option)
This won't make them move on your turn, but will provide you with an opportunity attack against them.
Take away their Reaction
An opportunity attack requires use of the reaction. If the enemy has already done an opportunity attack, used a readied action, or the like, they cannot take an opportunity attack. Likewise, the spells shocking grasp and arms of hadar prevents the target(s) from using reactions until the start of its next turn.
Also, if you are forced away by pushed or shoved you don't open opportunity attack. If you are afraid, and must move, you still will provoke an opportunity attack. So, if you can get the enemy or an ally to push you, you don't provoke an attack.