Peugeot also suffered its own heartache with former Dakar Rally leader Cyril Despres coming to a halt on the gruelling stage after losing a wheel and conceded chunks of time to fix a replacement wheel to tumble out of the top 20.
Joan Barreda Bort mastered the loose sand to win the stage by more than 10 minutes from KTM factory rider Matthias Walkner, catapulting him from 14th to fourth in the overall standngs, while his Honda team-mate Kevin Benevides was third for the day, two minutes further down, moving him up to within a minute of motorcycle leader Adrien van Beveren (Yamaha) in the overall standings.
Peterhansel, Loeb's team-mate who had been almost seven minutes clear on Tuesday and heading for a record 14th Dakar win, took the stage to extend his lead over Carlos Sainz to 31 minutes and 16 seconds.
His exit meant that Yamaha's French rider Adrian van Beveren took over the lead, one minute and 55 seconds clear of Chilean Pablo Quintanilla, after winning the stage.
"We thought by starting in a group it would be like a nice day out riding with your friends but as soon as we got to the dunes, the going got really tough". The KTM rider has been transported by medical helicopter to the bivouac after being ruled out of finishing the fourth stage. We lost pressure in one of the tires.
Toby Price during Stage 4 of the 2018 Dakar Rally. He finished the stage at 33rd position, which placed him at 24 position in the overall rankings.
"We started the stage today on the beach".
Loeb finished one minute 35 seconds ahead of teammate Carlos Sainz on Tuesday, and he was more than three minutes in front of compatriot and defending champion Stephane Peterhansel, reports Xinhua news agency. Dune section was really long and hard but I managed that well.
Mikko Hirvonen is happy with the start of 2018 Dakar Rally, despite making a small navigational error on the second stage of the endurance rally, resulting in lost time.
Peugeot's Sebastien Loeb during Stage 4 of the 2018 Dakar Rally.
Cyril Despres (Peugeot) and Nasser Al-Attiyah (Toyota) lost their places in the top three to Loeb and Sainz, who is third and around 13 minutes behind Peterhansel, after a awful day in the Peruvian desert.
The Gazoo Racing SA Toyotas fought back on Wednesday, with Dutch driver Bernhard ten Brinke ending up second on the stage, 4m32s behind Peterhansel and ahead of South African star Giniel de Villiers, Sainz and Nasser Al Attiyah.
Although Al-Attiyah still sits fourth overall, the 58 minute deficit leaves his and Toyota's hopes of overall victory reliant on trouble striking all three of the leading Peugeots.
With the WRC legend ruled out, his Peugeot teammates Peterhansel and Carlos Sainz were left standing as the two frontrunners in the vehicle class, and it was the former who bolstered his chances with a strong time through Wednesday's test.