Frenchman Loeb moved up from fifth to second overall with his third stage win of the event in a privately-entered Peugeot, pushing compatriot and 13-times Dakar winner Stephane Peterhansel down to third.
Loeb, a nine-times world rally champion who has yet to win the Dakar in three previous attempts, crashed out last year on the same stretch of terrain but he said he had "dodged the bullet" this time.
Peterhansel, in a Mini Buggy, lost 18 minutes and 49 seconds to Loeb in the 310km sandy sixth stage from the city of Arequipa to San Juan de Marcona, and is 41 minutes adrift of Toyota driver Al-Attiyah.
"I saw (Spaniard) Nani (Roma) stuck five kilometres from the finish. He didn't signal for help, but after he helped me out two days ago, I felt it was my duty to rush to his aid," said Peterhansel.
"As a result, I got stuck in a sand basin and lost 20 minutes. It wasn't a mistake, it was a real blunder. Victory's slipping away after too many mistakes."
Chilean rider Pablo Quintanilla took the lead in the motorcycle standings from American Ricky Brabec, now four and a half minutes behind, after winning the stage.
Britain's 2017 Dakar winner Sam Sunderland dropped from second to seventh after losing nearly 23 minutes to the leader during the stage.
The rally, which switched from Africa to South America in 2009 for security reasons and is now held entirely in Peru, finishes in Lima on Thursday. (Reporting by Alan Baldwin in London, editing by Ed Osmond)
(This story has not been edited by Devdiscourse staff and is auto-generated from a syndicated feed.)