MINI driver Sainz, was in a class of his own throughout the 12-day rally, which was being held in a Middle East country for the first time.
Having bagged four stage wins over the course of the marathon, Sainz and co-driver Lucas Cruz arrived into the final day of competition with a 10-minute buffer over Al Attiyah and Peterhansel.
Al Attiyah to fight back
Though he missed out on victory, Al Attiyah got his sixth podium in the last seven editions by beating Peterhansel to the runner-up spot. A crucial navigational error during the second half of the rally cost defending champions Al Attiyah and French co-driver Matthieu Baumel dear. Though, the three-time champion rued the mistakes, he vowed to come back strongly next year.
"I'm quite happy, we did a good job to finish second even though we wanted to win. We made two or three mistakes along the way and had loads of punctures, but I'm rather happy. I'm elated that we're racing here. I'm coming back to win next year. I just needed a bit more luck," the Toyota driver said.
Peterhansel, who has won the Dakar a record 13 times -- seven on four wheels and six on two -- did his best and had to be content with a third place, which was his 17th podium of an illustrious career.
Behind Peterhansel, local driver Yazeed Al Rajhi took his best Dakar finish in fourth place in his Overdrive Toyota while Al Attiyah's Toyota Gazoo Racing colleague Giniel de Villiers of South Africa finished fifth.
The surprise package was two-time Formula One champion Fernando Alonso, who passed the final stage 3min, 25sec slower than Al Attiyah, good enough for fourth-fastest on the day for an overall 13th-place finish.
The Spaniard also finished as top rookie on his debut with compatriot co-driver Marc Coma sitting alongside, despite several early delays and a roll in the dunes in the second half of the rally.