In a match that finished shortly before 1am local time, the Australian let slip a two-set lead to an inspired Gasquet but hit back to set up a quarter-final against American Andy Roddick.
"It was hard work for both of us," Hewitt said.
"He is a young guy on the rise. I was very wary coming out here tonight. This is where it all started for me, at grand slams, so it's good to get through to another quarter-final."
Gasquet said he had given it his all.
"I'm really tired," he said.
"It was a great match for me today. I fought a lot, I did my best today but he was too good."
Hewitt, the champion in 2001, eased through the first two sets before Gasquet roared back to level thanks to a series of crushing groundstroke winners.
With Gasquet struggling with cramp in the fifth set, Hewitt broke in the second game and though Gasquet saved two match points with outrageous winners, Hewitt served out to clinch victory after three hours 33 minutes.
More from rediff