The fourth stage of the rally camped itself in San Juan De Marcona for one more day of dunes and navigation.
The 13-time Dakar champion notched up his first stage win of the 2018 event, beating his nearest rival - Toyota's Bernhard ten Brinke - by nearly five minutes.
Australian rider Toby Price lost 13 minutes on the Yamaha rider but now sits sixth overall, just 10 minutes adrift, after his five minute penalty handed out at the end of Stage 3 was rescinded by officials.
His five-minute penalty from Stage 3 overturned, Price and Walkner were among a gaggle of riders within five minutes of the lead at the final waypoint, but the Australian would lose a further seven minutes before reaching the finish.
It was a tough day for Al-Attiyah; the current Cross-Country World Cup title holder started the day on a charge, and quickly made up some time over the leaders, only to be slowed by a gearbox problem.
Willem du Toit (KTM) posted his worst stage result yet on the Dakar, finishing 78th - but still moved up two places to 66th overall, while Gerry van der Byl posted his best finish yet in 112th, and moved up eight places to 111th. We lost pressure in one of the tires.
Xavier De Soultrait rides along the beach during Stage 4.
"I told myself I had to be calm and wait for the moment to pass the riders in front of me".
Loeb finished one minute, 35 secs ahead of teammate Carlos Sainz and over three minutes in front of defending champion Stephane Peterhansel, who remains the overall leader with a near seven-minute advantage over fellow Peugeot driver and compatriot Loeb.
Navigating a tough stage involving hidden way points and a hard terrain, Hero MotoSports Team Rally riders C S Santosh overcame a crash to gain over 40 places while Oriol Mena was ranked 24th overall in the Dakar Rally.
Peugeot's Sebastien Loeb during Stage 4 of the 2018 Dakar Rally.
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.
In the auto category, Qatari driver Al-Attiyah (Toyota Gazoo) won Tuesday's stage to move up to third overall, within eight minutes of France's Stephane Peterhansel (Peugeot), a 13-time victor in the Dakar.
With the WRC legend ruled out, his Peugeot teammates Peterhansel and Carlos Sainz were left standing as the two frontrunners in the auto class, and it was the former who bolstered his chances with a strong time through Wednesday's test.