Cannot play media. Sorry, this media is not available in your territory.
Blake had never beaten Federer before Thursday's encounter
Roger Federer's disappointing season continued as his hopes of winning Olympic gold in the men's singles were ended by an inspired James Blake.
Blake had not beaten the top seed in eight previous attempts but won their quarter-final 6-4 7-6 and will play Fernando Gonzalez in the semi-finals.
Second seed Rafael Nadal will play Novak Djokovic in the other semi-final.
Spaniard Nadal beat Jurgen Melzer 6-0 6-4 and Djokovic, from Serbia, defeated Gael Monfils 4-6 6-1 6-4.
In the other quarter-final 12th seed Gonzalez, who is from Chile and claimed the bronze medal at the 2004 Olympics, cruised past Frenchman Paul-Henri Mathieu 6-4 6-4.
I know I can beat the best in the world on my day and I proved it
Federer's conqueror James Blake
Federer, who will lose his world number one ranking to Nadal on Monday, made a number of unforced errors and will need a dramatic reversal in fortunes if he is to successfully defend his US Open title later this month.
"It's a big disappointment obviously. The Olympics was one of the goals of the season for me. So obviously the quarter-finals is not going to do it," he said.
"But I've still got to look forward to the US Open. I still have that and then the Masters Cup in Shanghai to really do well now and try and save my season.
"I think James played well. I can only really say how well he played. I've played him on many occasions, but I think this was the best I've seen him.
"I'm happy for him. I hope he can go all the way now."
Blake, the world number seven, had won only one set in his previous matches against Federer, but he unnerved the five-time Wimbledon champion with a near faultless service game and an aggressive forehand.
"I always believed in myself," said Blake. "I'd lost to him eight, nine, 10, 50 times, I don't know how many, but I had the feeling it could be my day.
"He didn't play a good first game and that put me up straight away. I played loose and free and I always fancy my chances on the 5-4 game.
"I know I can beat the best in the world on my day and I proved it."
The 28-year-old broke Federer when the Swiss was serving to stay in the first set and then broke again early in the second to take a 3-0 lead.
Federer, who was struggling with his serve and forehand, broke back in the fifth game to take the set to a tie-break only for Blake to win it after racing into a 4-1 lead.
Federer was due to play in the doubles quarter-finals with Stanislas Wawrinka later on Thursday against the Indian pair of Leander Paes and Mahesh Bhupathi but the match was postponed because of rain.