The athletic Muhammad Ali look-alike went shot for shot with the four-time Open champion throughout Wednesday night's quarter-final, with only a few critical points separating them as the Swiss great won 7-6 (7-4) 4-6 7-6 (7-4) 3-6 6-3.
It booked the second seed an enticing semi-final match-up with third seed Andy Murray on Friday night.
The Scot beat Federer in last year's Olympic Games gold medal match, after Federer had downed Murray in the Wimbledon final to claim his 17th major title.
With top seed Novak Djokovic and fourth seed David Ferrer through to Thursday night's semi, it means the top four seeds are the last four survivors in the men's draw for just the 15th time in a major in the open era.
While Murray cruised through his quarter-final against unseeded Frenchman Jeremy Chardy on Wednesday, Federer's clash with seventh seed Tsonga - coached by Australia's Roger Rasheed - couldn't have been much tighter.
Federer had not lost a set or even a service game previously in the tournament.
But Tsonga's mix of big serves, big shots, delicate touch at the net and court speed troubled the Swiss enormously as he dropped serve five times for the match.
In the second and fourth sets that proved decisive but in the first and third Federer's poise in the tiebreakers was invaluable.
In the first-set tiebreaker an over-rule fault call on Tsonga's first serve of the game proved critical as Tsonga lost that point, giving Federer an advantage which he maintained throughout.
In the third-set breaker, Federer produced an exquisite down-the-line backhand to grab a mini-break and 6-4 lead, then clinched it on his first set point.
Tsonga, who became the first man to beat Federer from two sets to love down in a grand slam match in the 2011 Wimbledon quarter-finals, refused to buckle or temper his aggressive game.
He roared through the fourth set, breaking Federer's serve twice.
A crucial unforced error on break point in the fourth game of the fifth set proved costly.
But Tsonga fought to the end, saving four match points on his own serve at 2-5, the third of those with a spectacular lunging volley, forcing Federer to serve it out.