Loeb completed 519 timed kilometres between Tacna and Arequipa in just under five hours to pick up his second stage win of the marathon.
In what was the longest special of Dakar 2019, leader Nasser Al-Attiyah gave up just over 10 minutes to Loeb, leaving the nine-time World Rally champion with another 40 minutes to make up if he's to challenge the Qatari Toyota driver for overall victory.
Al-Attiyah's hopes of a third Dakar triumph received a further boost as his nearest rival Peterhansel suffered a late setback in his X-raid Mini buggy.
Peterhansel and Al-Attiyah were opening the road after a side-by-side start, and it was the 13-time Dakar champion who had the initial advantage.
But Al-Attiyah quickly turned the tide of the battle, and arrived at the neutralised zone two-thirds of the way into the test two minutes clear.
Peterhansel then dropped almost a quarter of an hour in the final stretch to end up 25 minutes behind Al-Attiyah in the general classification.
X-raid Mini 4x4 drivers Nani Roma and Kuba Przygonski likewise lost time relative to Loeb and Al-Attiyah in the run-up to the finish, although Roma did beat Peterhansel to third place on the day.
The Spaniard now sits 34 minutes behind Al-Attiyah, while FIA cross-country world champion Przygonski is a further four minutes adrift.
Yazeed Al-Rajhi, who was on the heels of fellow Mini 4x4 drivers Roma and Przygonski in the general classification heading into the stage, dropped out of victory contention, giving up two hours even before the neutralised zone.
Cyril Despres was nearly 33 minutes off the pace in his X-raid Mini buggy, leaving fifth-placed Loeb as the last driver within an hour of Al-Attiyah in the standings.
The 2019 Dakar Rally will resume on Sunday after a single rest day in Arequipa.
Standings after Stage 5 (Cars class, Top 10):
|1|| Nasser Al-Attiyah |
|3|| Nani Roma |
|6|| Cyril Despres |
|10|| Yazeed Al-Rajhi |