Let’s take US Open 2019 as an example
The July 15 edition of the ATP Rankings was used to determine the US Open main-draw entry list. That is more than a month prior to tournament start.
104 slots given to Direct Entries + Protected Ranking (PR)
16 slots are taken by Qualifiers
8 slots are awarded to Wild Cards
You get a Direct entry if you are ranked high enough.
What is 'high enough' is determined by 2 factors:
- Number of PRs
- Number of Withdrawals (players that were accepted directly into the main draw, but withdrew due to injury, suspension, or personal reasons)
Direct Entry threshold = 104 - PR + Withdrawals
For US Open 2019 that is 104 - 6 + 2 = 100. So players ranked 1–100 got a direct entry into the tournament. Players that ranked above 100 and did not have a PR had to play qualifiers to get into the main draw.
Hence, Denis Kudla, ranked 100 got a direct entry, Malek Jaziri ranked 101 had to play qualifiers (and lost).
In case of late withdrawals (e.g. when Qualification is already finished), the slot will be given to a Lucky loser, i.e. one of the players that lost in the final round of Qualification. If the tournament has no qualifying rounds(e.g. ATP Finals) the spot is picked by an Alternate.
There is also the Special Exempt - Players who are unable to appear in a tournament's qualifying draw because they are still competing in a previous tournament can be awarded a spot in the main draw by special exempt.
The rules differ depending on the tournament level, e.g. for ATP Masters:
A Qualified event for special exempt to an ATP Tour Masters 1000 tournament is the singles event of another ATP Tour Masters 1000, ATP Tour 500 or
Grand Slam tournament