Australian Open champion
Celebrations have been rare for Roddick in recent times.
A series of injuries and illnesses have seen the 2003 US Open champion tumble down the world rankings to 34 and taken their toll on the man who pushed Federer all the way in a marathon final for the 2009 Wimbledon crown.
However, in front of a packed crowd under the lights at Crandon Park, Roddick raised his arms in triumph after a display of power hitting and big serving that gave him just his third win in 24 encounters with Federer.
After Roddick edged the first set in a tiebreak, Federer fought back strongly in the second.
But the match turned decisively in Roddick's favour early in the third set when Federer missed out on three chances to break in the second game and then was broken himself in the next.
Roddick never let loose of his grip to end a Federer winning streak that took him two titles in Rotterdam, Dubai and Indian Wells.
The defeat also finished a Federer run of 77 consecutive victories against players outside the top 20.
"I felt like a lost against a former number one, not a guy ranked in the thirties," said Federer, who added he had felt a little flat.
"It's been maybe 30 matches this season. I am just feeling like it's taken its toll a bit, which is normal.
"But I've played more tired in the past, so this was not the most tired I have ever been, but you just start to feel it a bit. I didn't just get the lucky break today that I got in Indian Wells."
Roddick will next play Spain's
"You don't get to enjoy it for long. The process starts now getting the body to recover after a late night and getting it ready to go again," Roddick said.
"As much as you want to take it in, because obviously these wins are few and far between, you have to get ready," he added.
World number one Djokovic broke Troicki three times en route to his 11th consecutive win over his compatriot to set up a fourth round match against Frenchman R
Gasquet, who has been a quarter-finalist in four tournaments so far this year, beat Spain's
Fish advances to face Spain's 12th seed
Rounding off the day's results, number 11 seed