KEY BISCAYNE, Fla. (AP) — Roger Federer lost his second consecutive match and the No. 1 ranking Saturday.

Big-serving Australian Thanasi Kokkinakis, a qualifier ranked 175th, rallied to upset Federer 3-6, 6-3, 7-6 (4) at the Miami Open. The 36-year-old Federer had been the oldest No. 1 man ever, but he'll lose that spot to Rafael Nadal when the new rankings come out April 2.

"I deserve it after this match," Federer said. "That's how I feel."

Kokkinakis became the lowest-ranked man to beat a No. 1 player since No. 178 Francisco Clavet upset Lleyton Hewitt in 2003. That upset was also at Key Biscayne.

"Pretty crazy," said Kokkinakis, 21. "I'm pretty happy about it."

Federer now has lost back-to-back matches for the first time since 2014, a dip that comes after a career-best 17-0 start to the year. He lost to Juan Martin del Potro in the Indian Wells final Sunday, a defeat that also came down to a winner-take-all tiebreaker.

Did the losses have anything in common?

"Yes, 7-6 in the third," Federer said. "Other than that, not much."

The 6-foot-5 Kokkinakis has long been regarded as a promising talent thanks to a thunderous serve and forehand, but has been plagued by injuries. The match was his first against Federer, although they've practiced together.

"I've always liked his game," Federer said. "I'm happy for him that on the big stage he was able to show it. It's a big result for him in his career, and I hope it's going to launch him."

Federer's defeat left both No. 1 players out of the tournament. Simona Halep lost hours earlier to Agnieszka Radwanska 3-6, 6-2, 6-3. Eight-time women's champion Serena Williams and six-time winner Novak Djokovic were also eliminated in their opening matches.

Federer won't be playing to reclaim the No. 1 spot anytime soon. He said he'll skip the upcoming clay season for the second year in a row, including the French Open.

During a stadium ceremony before the night session, tour professionals joined members of the boys' and girls' tennis teams at Marjory Stoneman Douglas High School to promote a fundraising campaign for victims of last month's mass shooting there.

Federer's match turned when he played a poor service game and was broken at love to fall behind 3-1 in the second set.

"That game I knuckled down and put pressure on him," Kokkinakis said. "I started to dictate from there."

Kokkinakis never broke again but held the rest of the way, consistently topping 125 mph with his serve.

"Every time I had chances, something bad happened," Federer said. "Wrong decision-making by me, good decision-making by him. It's disappointing. I don't know why I couldn't get to any level I was happy with today."

Federer kept one exchange going by hitting a volley behind his back, but couldn't win even that point. He laughed then — it was early in the match — but looked grim two hours later as the end neared.

On match point, Federer buried a backhand return in the bottom of the net. Kokkinakis screamed in celebration, waved his index finger and gestured for more noise from the appreciative capacity crowd.

Kokkinakis said he didn't mind that fans were firmly in Federer's corner during the match — and even before it.

"When I came on court there wasn't much cheering," Kokkinakis said with a laugh. "He came on court with a little delay and that sort of strut he does, and I was like, 'This is pretty nuts.' The crowd goes nuts when he does his walk onto court."

The walk to the exit was the last at Key Biscayne for Federer, a three-time champion. The event is moving next year to the Miami Dolphins' stadium.

Nadal will become the new No. 1 even though he missed Key Biscayne because of a hip injury that also forced him to skip Indian Wells.

Kokkinakis is healthy for a change. The tournament is just his fifth in the past seven months, but he said he thought he could beat Federer.

"When I'm playing on my terms, I don't feel there are too many people that can go with me," Kokkinakis said. "I just needed to play my game and aggressive tennis."

_

More AP tennis coverage: https://apnews.com/tag/apf-Tennis