KEY BISCAYNE, Fla. -- Techno music rocked the stadium during a changeover, then faded, the din replaced by the crowd's cheers as Andy Roddick took his position at the baseline, one game from a win over nemesis Roger Federer.

Roddick held the balls, and that was the edge he needed. He served out the match to win 7-6 (4), 1-6, 6-4 Monday night in the third round at the Sony Ericsson Open.

With that, the fans roared again, saluting only the third victory for Roddick in 24 meetings with Federer.

"There is no script in sports, you know. I think that's what makes it the best entertainment in the world," Roddick said. "Nights like tonight are why you play the matches. You don't know what's going to happen."

On paper, it looked like a mismatch between former No. 1s, each a two-time champion in the event. The third-ranked Federer began the night 40-2 since the U.S. Open, while Roddick's ranking had slipped to 34th, his lowest point since 2001.

But Roddick's serve kept him in the match, and then won it. He broke only once but held every service game in the first and last sets.

After falling behind 15-30 in the final game, he closed out the victory with an ace and two service winners, all at more than 130 mph. That ended Federer's streak of 77 consecutive wins against players outside the top 20.

"I feel like I lost against a former No. 1, not that I lost against a guy ranked 30 in the world," Federer said. "I'm happy to see Andy play really well. He's a great champion, and enjoy him while you have him. It was a great night for him and America's tennis."

No. 1 Novak Djokovic advanced to the fourth round by beating No. 27-seeded Viktor Troicki 6-3, 6-4. Djokovic is bidding for his third Key Biscayne title and second in a row.

No. 8-seeded Mardy Fish assured he'll remain the top-ranked American man by beating No. 28 Kevin Anderson 6-4, 6-3.