KEY BISCAYNE, Fla. — Roger Federer suffered one of the more shocking defeats of his career on Saturday, losing to a qualifier ranked 175th in a result that will also cost him the No. 1 ranking.

Thanasi Kokkinakis, who needed a wild card just to get into the qualifying rounds of the Miami Open, stunned Federer, 3-6, 6-3, 7-6 (4), in the second round in front of a large crowd that tried to will Federer to victory.

Kokkinakis, a 21-year-old Australian, had debated retiring after a string of injuries over the last two years. He became the lowest ranked player to beat a No. 1 since Francisco Clavet, then No. 178, beat Lleyton Hewitt at this tournament in 2003.

Federer, the defending champion, will cede the No. 1 spot to the current No. 2, Rafael Nadal, when the new ATP rankings come out on April 2.