Berdych had lost his previous eight meetings with Federer
Roger Federer suffered a shock 6-4 6-7 (3-7) 7-6 (8-6) defeat at the hands of Czech Tomas Berdych in the fourth round of the Sony Ericsson Open in Miami.
Top seed Federer was within two points of defeat at 5-6 in the second set but hit back to earn a match point in the deciding tie-break.
He failed to capitalise and a wayward forehand three points later gave victory to world number 20 Berdych.
Spain's Rafael Nadal and American Andy Roddick advanced to the last eight.
But Federer was left to reflect on his second surprise defeat since beating Britain's Andy Murray in the Australian Open final in January, having lost to Cypriot Marcus Baghdatis in the third round of his last tournaent at Indian Wells.
"I had tons of chances at the end. I tried everything I could. It is just not happening for me at the moment," said Federer.
"But I fought as much as I could under the circumstances with my game having issues at the moment.
After threatening to finish the match in straight sets, Berdych could not press home his advantage at 15-30 up in the 12th game of the second set.
Four unforced errors on his previously dangerous forehand allowed Federer to take the match into a decider, but, after trading a break apiece, Berdych held his nerve for a magnificent win.
His reward is a quarter-final clash with Spain's Fernando Verdasco who overcame Marin Cilic 6-4 7-6 (7-3).
Sixth seed Roddick, meanwhile, recovered from a poor start to eventually book his place in the quarter-finals with a 7-6 (7-4) 6-3 win over German Benjamin Becker.
The American trailed 1-4 and 0-40 in the first set before pulling himself together to set up a match with Spain's Nicolas Almagro.
"When things aren't going my way, I'm probably better now," said Roddick. "Six years ago on the court my highs were a lot higher, and the lows were a lot lower."
Fourth seed Nadal beat fellow Spaniard and 15th seed David Ferrer 7-6 (7-5) 6-4 and will next play eighth seed Jo-Wilfried Tsonga, who dismantled former world number one Juan Carlos Ferrero 6-2 6-2.
The Frenchman turned in a fantastic performance as he dropped just four points on his first serve.
Murray's conqueror Mardy Fish bowed out of the tournament when he was forced to retire while trailing 6-1 1-0 against 13th seed Mikhail Youzhny.
Fifth seed Robin Soderling of Sweden went through with a 6-0 6-7 (3-7) 6-2 victory over Chile's Fernando Gonzalez, the ninth seed.