Last updated on .From the section Tennis

Roger Federer failed to reach the French Open quarter-finals for the first time since 2004 as he lost in five sets to Latvia's Ernests Gulbis.

Analysis Annabel Croft BBC Radio 5 live "I've been watching Ernests Gulbis since 17 here and we saw what potential he had but then he never kicked on. It is a shame it took him so long to realise the level he is showing but thankfully he has. He fully deserved the win. "The more losses Roger Federer has like this the more players will feel they can beat him more regularly."

The 17-time Grand Slam champion led by a set and a break, but went down 6-7 (5-7) 7-6 (7-3) 6-2 4-6 6-3.

Fourth-round victory would have taken the 32-year-old Swiss into a record 42nd major quarter-final.

Gulbis, seeded 18th, goes on to face sixth seed Czech Tomas Berdych in the last eight.

The temperamental 25-year-old gave a typically unpredictable performance, big serving and brilliant shot-making interspersed with racquet smashing and verbal exchanges with spectators.

"It's probably the most important win of my career, especially because it was five sets," said Gulbis.

"I beat him before, but it was a three set match. So for my confidence and just for me as a tennis player, a five set win over Roger Federer, it's really big."

There was no doubt where the crowd's affections lay on Court Philippe Chatrier, with 2009 champion Federer given the support of a home player.

The Swiss looked in control when he served for a two-set lead, but he inexplicably failed to put away a smash on set point, and the afternoon took a very different turn.

Match stats Gulbis Federer 13 Aces 7 4 Double faults 3 60% 1st serve % 63% 70% 1st serve win % 69% 61% 2nd serve win % 51% 53 Winners 42 53 Errors 59 7/12 Break points 5/7 Match time: 3 hr 42 mins

Gulbis came back to win the tie-break and broke serve twice to move into the lead in the third.

Chants of "Roger, Roger" rang around the stadium as the crowd tried to lift their man, and Federer responded by taking the fourth set.

He was made to wait at 5-2 while Gulbis left the court for a medical timeout, though, and the Latvian almost recovered two breaks as he regained the momentum.

Federer slipped to 0-40 in his first service game of the decider and, after saving two break points, he hammered the third wide.

Try as he might, and urged on by the crowd, Federer could not not recover the deficit.

Gulbis held him off brilliantly under pressure at 4-2 with two huge serves and a deft drop shot, and coolly served out the win after three hours and 42 minutes.

"I was all over the place," said Federer. "I am disappointed not to win. I have a lot of regrets.

"But he did a good job of hanging around and coming back. I knew what to expect, I know how he plays. I just wish I could have played better."