KEY BISCAYNE, Fla. (AP) — The hour was past midnight when Roger Federer found himself one big serve from salvaging a sloppy victory.
He couldn't summon the shot he needed.
"It was almost impossible to get it past the other guy with the serve," Federer said.
Slow conditions were one problem for the world's No. 1-ranked player Tuesday night at the Sony Ericsson Open. Erratic groundstrokes were another. And then there was Tomas Berdych, who advanced to the quarterfinals by outlasting Federer 6-4, 6-7 (3), 7-6 (6).
"I fought as much as I could," Federer said. "My game has issues at the moment. I'm definitely lacking timing. I don't know where that comes from."
Fans in the packed stadium tried to help. Some shouted encouragement in Spanish, which is not one of the six languages Federer speaks. One man hollered in English, "I love you, Roger!" Another barked, "Get it together."
But Federer could never quite get over the hump.
"It fuels my desire to go back to the practice courts and come back even stronger," said Federer, who now begins his clay-court season. "I don't like to lose these type of the matches."
With the upset, the No. 16-seeded Berdych ended a streak of eight consecutive losses against Federer. The 6-foot-5 Berdych also had lost 11 matches in a row against top-10 opponents.
Others advancing to the quarterfinals included Andy Roddick and Rafael Nadal, who could meet in the semifinals.
Roddick beat Benjamin Becker 7-6 (4), 6-3. Nadal defeated fellow Spaniard David Ferrer 7-6 (5), 6-4.
Three-time champion Venus Williams reached the semifinals by defeating No. 6-seeded Agnieszka Radwanska 6-3, 6-1.
Federer won a succession of spectacular rallies to salvage the second set, but he converted only two of 10 break-point chances in the match and committed a whopping 62 unforced errors, many on an unreliable backhand.
Grand Slam titles: Federer 16, Berdych 0. Total points in the match: Federer 119, Berdych 119. But Berdych won the last one when Federer sailed a forehand long at 12:16 a.m.
"After a game like that, the feeling is great," Berdych said. "I'm really happy the way I finish it."
Federer held a match point serving at 6-5 in the tiebreaker. But Berdych hit a forehand winner into the corner, then wagged his tongue in relief.
Federer had problems from the start, committing 18 errors to four by Berdych in the first nine games. In a stunning lapse, Federer lost the final eight points of the opening set, double-faulting on set point.
He was twice two points from defeat in the second set before pulling it out, but his shotmaking became more erratic again in the final set. He rallied from a break down before hitting five errant groundstrokes in the decisive tiebreaker.
"I'm a bit confused with how I'm feeling the ball at the moment," Federer said. "Sometimes it flies and sometimes it doesn't."
The upset spoils the prospect of a Federer-Nadal final. The archrivals haven't met since last May in Madrid.
The No. 6-seeded Roddick rallied past Becker on the strength of his dominating serve. He dug out of a 1-4, love-40 hole in the first set and won 34 of his final 39 service points, including all six in the tiebreaker.
Roddick said experience helped with the turnaround.
"When things aren't going my way, I'm probably better now," he said. "Six years ago on the court my highs were a lot higher, and the lows were a lot lower. If I would have gotten down early, I don't know if I would have stayed the course."
No. 8 Jo-Wilfried Tsonga earned a shot at Nadal on Wednesday night by beating No. 12 Juan Carlos Ferrero 6-2, 6-2. The fourth-seeded Nadal, seeking his first Key Biscayne championship and his first title anywhere in 10 months, punctuated his win over Ferrer with a nifty leg kick-uppercut combination.
Williams' opponent Thursday will be No. 13 Marion Bartoli, who beat No. 12 Yanina Wickmayer 6-4, 7-5.