The Qatari driver, who had lost time to his rival yesterday, recovered more than eight minutes over Peterhansel to finish the day just 1:18 minutes behind the Frenchman following the 438-km special from Arica to Calama.
Al-Attiyah completed the special in four hours and 52 minutes to clinch his third stage victory of this year's Dakar. Peterhansel was second, ahead of American Robby Gordon, who was nearly 14 minutes behind Al-Attiyah at the finish.
Argentina's Orlando Terranova was fourth in the BMW X3, while Russian Leonid Novistkiy completed the top five.
South African Giniel de Villiers finished the day in sixth to keep third position in the standings, albeit over 42 minutes behind the leader.
Al-Attiyah's team-mate and former world rally champion Carlos Sainz, already out of contention after the problems he had suffered on Tuesday, was forced to retire from the event after being hit by engine problems in his Red Bull buggy.
Peterhansel's x-Raid team-mate Nani Roma, the winner of yesterday's stage, also hit trouble and lost all chances of fighting for the overall victory after getting stuck in a dune and losing over an hour to Al-Attiyah.
The rally will enter Argentina tomorrow with a 218-km special from Calama to Salta.