(Adds details, quotes)
PARIS, June 2 (Reuters) - Second seed Roger Federer produced a thrilling riposte to Gilles Simon's gallant attempt to knock him out of the French Open on Sunday to claim a 6-1 4-6 2-6 6-2 6-3 victory in front of a raucous late-evening crowd on Philippe Chatrier Court.
Averting a mounting crisis in the middle of a spectacular match, Federer won the last two sets to reach his 36th consecutive grand slam quarter-final and keep alive his hopes of a second title at Roland Garros.
When 15th seed Simon, roared on by chants of "Gillou", won the third set, Federer looked to be in danger but the 17-times grand slam champion hit back with every weapon in his arsenal to set up a quarter-final with another French hope, Jo-Wilfried Tsonga.
It was nerve-wracking until the end, however, with Federer missing an easy volley when serving for the match at 5-3 to offer Simon hope of a late escape.
Federer then wasted his first match point with an anxious forehand swiped into the net but when a second opportunity came his way Simon pushed a backhand into the tramlines.
"It was beautiful, it's always special to play matches like that," 2009 champion and firm Paris favourite Federer said at courtside. "You always remember matches like this."
The victory was 31-year-old Federer's 58th at the French Open, making him joint leader with Guillermo Vilas and Nicola Pietrangeli on the all-time list of matches won here.
The Swiss had to dig into his vast repertoire of strokes to subdue Simon - a player who has troubled him before and who won the first two of their five previous meetings.
There were the delicate drop shots, lob volleys, the backhand slices that seem to hang in the air for eternity and then those explosive forehands that few players can return.
Federer even managed to curl one winner between the outside of the net post and the umpire's chair to give him a sixth and final set point in the opener.
Everything looked under control for Federer until he stumbled and fell in the sixth game of the second set.
There was no obvious damage but he was broken in the next game and Simon rammed home the advantage to level the match.
A flustered Federer dropped his serve twice in the third set as Simon, bidding to reach the quarter-finals at his home grand slam for the first time, sensed his chance for a huge upset.
Federer has made a career out of pulling out the stops when required, however, and quickly restored order, overpowering a tiring Simon in the fourth set with some belligerent tennis.
An early break in the fifth gave Federer breathing space and despite a few nervous moments at the end he claimed the 900th Tour victory of his career. (Reporting by Martyn Herman; Editing by Sonia Oxley)