The basic answer is "it doesn't" - the anime was not canon to the games. The games' timeline is:
3: Dante is young, hasn't started his agency yet, we meet Virgil as a human (well, half human), he meets Lady.
1: Dante meets Trish and we learn Virgil became Nelo Angelo.
4: Both Lady and Trish are in this.
2: Dante becomes trapped in the underworld and we never learn what happened after because they did a stupid reboot instead of a sequel for DMC 5. These events are not mentioned in other games so it is the final game in the timeline. There are no official canon works that make reference to what happened after.
In the anime he knows both Lady and Trish so it is set after 3 and 1 and before 2. It could be before or after 4 but I would guess before since the anime was made before the game however there's no real answer because, as I said, the anime is not canon to the games.
I don't have links or anything because this is just from my memory - I owned all games (sold my copy of DMC 5) including the DMC 3 Special Edition (where you get to play through Virgil's story), two novels, and have the whole anime on my hard drive and have watched all episodes at least twice.