Barreda had entered the shortened 464km Al Ula-Yanbu stage fourth overall and with 15 minutes 40 seconds to make up on Honda teammate Kevin Benavides.
Starting second, the Spaniard quickly caught and surpassed teammate Ricky Brabec, who opened the road, and had pulled more than two minutes clear at the 127km mark.
At the next waypoint, located at 215km, Barreda was credited with a lead of over seven minutes over his nearest rival, KTM's Sam Sunderland, and 12 minutes over Brabec.
However, it soon emerged this was because Barreda had not made his mandatory refuelling stop at the 174km mark.
Dakar rules state that in-stage refuelling takes place during a 20-minute neutralisation period, which is deducted from the competitor's final time automatically.
After 267km, Barreda ran out of fuel, thus ending his hopes of scoring a first Dakar title in what he has admitted could be his final appearance in the event on a motorcycle.
Had Barreda somehow been able to keep going without stopping for fuel, he would have been set for a heavy penalty that would have all but ended his hopes anyway.
Honda is still on course to win the Dakar however, and Benavides looks well-positioned to extend his overall lead ahead of Friday's final stage.
At the 306km mark, he trailed Sunderland by just under three minutes but critically was over six minutes clear of Brabec, who began the stage only 51 seconds in arrears.