Magnussen's team-mate, Jenson Button, set the pace earlier in the day and his 1m25.030s effort stood until mid-way through the afternoon.
The 2008 world champion's 1m23.952s lap was the quickest of the week so far, surpassing Button's day two best, but another red flag almost immediately halted proceedings again after Adrian Sutil crashed his Sauber approaching Turn 7.
Jerez F1 test in pictures
After a fifth stoppage, for Jean-Eric Vergne's stranded Toro Rosso, there was around 40 minutes left of the session.
Magnussen, who had only taken over from Button with two and half hours of running remaining, then went out on Pirelli's medium tyre. He set two laps good enough to topple Hamilton, the best being 1m23.276s.
Williams continued its fine testing form with second, Felipe Massa setting a 1m23.700s in the closing minutes to also move ahead of Hamilton.
With Fernando Alonso's best on mediums, set early in the afternoon, only being 1m25.495s, it meant the top four drivers were all Mercedes powered.
Once again, the German marque also looked good in terms of mileage, Hamilton covering 62 laps, while McLaren's MP4-29 managed 92 with Button's and Magnussen's stints combined.
Force India struggled to get many laps in, Hulkenberg only completing 17 between issues, but a late run allowed him to claim sixth fastest time.
Gary Anderson's verdict on Red Bull's troubles
Once again, the Renault teams struggled. Ricciardo only managed three laps before Red Bull gave up running once again, while Robin Frijns also failed to complete a flying lap for Caterham.
Only Vergne set a lap time in a Renault-powered car - his 1m29.915s being comfortably the best Renault time of the week so far - but the Toro Rosso caused two red flags and managed only 30 laps.
Before his crash, Sutil had continued racking up the mileage for Sauber, albeit some way off the pace of the frontrunners.
Marussia's new car appeared for the first time. The squad was happy to complete a successful installation lap with Max Chilton, but the MR03 failed to set a flying lap.
- Motor Racing
- Sports & Recreation
- Lewis Hamilton
- Fernando Alonso
- Jenson Button
- Daniel Ricciardo
- Adrian Sutil