Two-time Miami champion Roddick bested the Swiss superstar 7-6 (7-4), 1-6, 6-4, saving all four break point opportunities in the decisive third set.
The American fired seven aces in the final set against Federer, ranked third in the world, who also boasts a pair of Miami championships. It was just the third time in 24 tries Roddick has beaten Federer.
Roddick will face Argentina's Juan Monaco in the round of 16. Monaco defeated Frenchman Gael Monfils 4-6, 6-3, 6-4.
World No. 1 Djokovic needed 85 minutes to get by 27th-seeded fellow Serb Viktor Troicki 6-3, 6-4, winning three service breaks to only one for Troicki.
Djokovic moves on to face Frenchman Richard Gasquet, who outlasted Spain's Albert Ramos, 6-2, 5-7, 6-3.
Spanish fifth seed David Ferrer dispatched 30th-seeded Frenchman Julien Benneteau 7-6 (7-5), 6-4 to reach the round of 16, while No. 8 seed Mardy Fish of the United States downed No. 28 Kevin Anderson of South Africa 6-4, 6-3.
Fish will next face 12th-seeded Nicolas Almagro, who cruised past 20th-seeded fellow Spaniard Fernando Verdasco 6-3, 6-4.
2014: The Year in Music [PHOTOS]