NEW YORK -- Canadian Milos Raonic almost made it to his first-ever Grand Slam quarter-final but fatigue got the best of him.

France's Richard Gasquet out-lasted Raonic 6-7 (4), 7-6 (4), 2-6, 7-6 (9), 7-5 on Monday in the fourth round of the U.S. Open.

Raonic, from Thornhill, Ont., hammered 39 aces and struck 102 winners, but it was not enough to hold off Gasquet during the closing stages of the four hour 40 minute marathon.

"He played better down the stretch than I did. I think that was pretty clear," said Raonic. "He created a lot more opportunities. I struggled a lot more on my service games.

"I think that's pretty much what it came down to. Playing that way in the end, it only matters who wins that last point."

The loss is only the fourth five-set match of Raonic's career. Montreal's Mike Belkin is the last Canadian to reach the final eight of a Grand Slam. He did it in the Australian Open in 1968.

Raonic matched his previous best at a Grand Slam. He'd made the fourth round in the Australian Open (2011, 2013) and the U.S. Open (2012).

Raonic missed on a match point chance in the fourth set on an error as Gasquet fought on to win an eventual tiebreaker and take the match into a deciding fifth set. The U.S. Open is the only Grand Slam tournament that does not play out the final set.

Raonic's legs were gone in the fifth set as he struggled to recover a break for 2-2 but losing his edge in the 11th game as he was broken from a weak forehand into the net on the first of three Gasquet chances to trail 5-6.

"I played a little bit too defensive," said Raonic. "That's really the only thing. You just need to convert on one of those chances, that's it."

Gasquet reached his second Grand Slam quarter-final a game later as Raonic returned long. He'll face Spain's David Ferrer in the next round of the U.S. Open.

The loss leaves Raonic at 32-16 on the season and 21-12 at Grand Slams.

Raonic had a battle in the opening set against Gasquet, whom he beat in their only previous match on Cincinnati hardcourt in 2012. He went down a break in the second game but got it back in the third.

Raonic pushed over two consecutive double-faults to lose serve after holding a set point in the tenth game, with Gasquet levelling at five apiece.

In the tiebreaker, Raonic finally prevailed to end the one-hour set on his second chance with a forehand winner to the corner. A frustrated Gasquet threw his socks onto the court at the changeover but retrieved them before the second set began.

Raonic dropped the tight second set in a tiebreaker but broke open his big game in the third set to sweep with the loss of just two games.

Gasquet profited from his opponent's ninth double-fault of the evening to earn a fourth set point that took it into a fifth set on a Raonic forehand to the net after more than three hours of play.