The number two seed came through 7-6 4-6 7-6 3-6 6-3 in a high-quality match that could have gone either way.
Federer was able to break his opponent in the opening game. Tsonga failed to find many telling serves, and rushed to the net on break-point only to drop his volley wide.
The Swiss had no such problems, holding his serve to love as the Frenchman's unforced error count increased early on.
Federer was made to save a break-point in his next service game as Tsonga showed signs of improvement, and then at 3-2, Tsonga got the break back after hitting a superb forehand return and matching his opponent from the baseline.
By the end of the first set it was Tsonga who was in the ascendancy. Some clever angles and two powerful forehands saw him win his final service game to love. Federer held his own serve though, and the set went into a tie-break.
The number two seed raced into an early lead, and although Tsonga came back with some excellent passing shots, Federer won the tie-break 7-4 to take the set.
Tsonga, annoyed at losing the first set, started to improve at the beginning of the second. He broke Federer in the seventh game and didn't look back; an ace and a couple more unforced errors from the Swiss gave Tsonga three set points and he duly levelled the match.
The two men exchanged service games at the start of the third set but both players started to find their very best tennis as the set wore on. Neither man was able to make any inroads on his opponent's serve, forcing another tie-break.
Two surprising forehand misses from Federer allowed Tsonga back into the contest, but at 3-3 two sublime shots from the same side put him back in the lead. A fired-up Federer then produced two even better backhands and took the third set to a standing ovation.
A very good forehand pass opened up three break points for Federer in the third game of the fourth set. Tsonga saved them all with some excellent ground strokes and powerful serving. A huge forehand saved a fourth break point and an ace saw the Frenchman escape, 2-1 up.
In the next game, it was Federer who had to save break points, which he did, as both players continued to showcase their shot-making prowess.
It was Tsonga who made the breakthrough, when the younger man's incredible power and accuracy proved too much for Federer in the sixth game. A rare dip on his serve though, allowed the number two seed to break back immediately.
Yet another superb cross-court forehand brought another break point, which Tsonga took with an assured volley. The players exchanged shot after shot in the next game, to regular gasps at the quality from the crowd, but it was Tsonga who came out on top and took the set 6-3.
Tsonga's ever-excellent backhand let him down early in the final set, allowing Federer to break at 2-1.
A fortunate flick off the net, to which both players saw the funny side, gave Federer the opportunity for a double-break. A rare miss with a volley, followed by a big Tsonga forehand, saw the chance slip away though.
Tsonga did force his illustrious opponent to serve out the match, saving four match points in amazing style to hold at 5-3. Federer made no mistake, winning with an overhead smash.
Andy Murray awaits Federer in the semi-final.