Al-Attiyah was at or just off the stage lead through to the fourth waypoint before Loeb (Peugeot, French) took over as pace-setter.
The nine-time World Rally Champion ended the 360km special between San Juan de Marcona and Pisco up by 7:27s on the Toyota driver, who was runner-up on the day.
Stephane Peterhansel (French) handed a big advantage to Al-Attiyah when the X-Raid Mini driver twice found himself stuck in dunes and fell from 29:16s to 53:30s behind in the general classification.
“There are still two days of the Dakar left and we're quite happy with it going like this until now,” said Al-Attiyah.
“We work day by day. I'm quite happy today that we finished with a good pace, but still we need to wait a little bit.
“Maybe there are other drivers that are faster, but our main target is Stéphane and now he is behind, so we'll try to manage the next two days.”
Nani Roma (Mini, Spanish) has in fact become the Qatari's closest rival on the general classification, 16 seconds ahead of Loeb, with Peterhansel fourth.
The latter wasn't the only one to strike trouble in the dunes, with team-mate and compatriot Cyril Despres now over two hours off the lead but remains fifth in Cars.
CLICK HERE for the Bikes report.
There has been a major shake-up in the trucks with sand also trapping Eduard Nikolaev, who was almost an hour slower than Kamaz team-mate Dmitry Sotnikov and is now second to his fellow Russian by 26:49s in the general classification.
Nicolas Cavigliasso (Yamaha) moved ever closer to the Quads title with another stage win that has the Argentine out in front by 1:24:52s.
SxS was a somewhat similar story as Reinaldo Varela (Can-Am, Brazilian) dropped from the lead to fourth, over 80 minutes away from new front-runner Francisco Lopez Contardo (Can-Am, Chilean), after he got beached at kilometre 97.
Stage 9 spans 313km of special stage (except Trucks: 311km) in a loop from Pisco.
General classification: Cars