Peterhansel won the seventh stage. AP Photo / Ricardo Mazalan.

Lima - Stephane Peterhansel won the seventh stage of the Dakar Rally in Peru on Monday to take back second place and cut Nasser Al-Attiyah's overall lead to 29 minutes.

The Frenchman, a 13 times Dakar winner, gained a position from compatriot Sebastien Loeb after the nine times world rally champion lost half an hour with an electrical problem in his Peugeot.

"We got a bit closer to Nasser, but it'll be very hard to wrest the lead from him," said Peterhansel, who beat Spaniard and fellow Mini driver Nani Roma for his second stage win of the endurance event.

"Actually, we don't deserve to be ahead of him because he's doing really well and has made no mistakes so far."

Roma moved up to third overall, with Loeb dropping back to fourth.

Toyota Gazoo Racing SA Hilux driver Al-Attiyah completed the stage with the fourth fastest time but 12 minutes slower than Peterhansel, with 785km of timed competition before the finish in Lima on Thursday.

Al-Attiyah remains in the lead, but Peterhansel is on the charge. Picture: Toyota SA.

"Today was difficult, we knew Stephane was going to attack. We lost 11 or 12 minutes, but we've still got about half an hour in the overall," said the Qatari, who had started the day more than 37 minutes clear.

"We'll see what we can do these last three days. One of our rear tyres had a puncture with 10 km to go, but we decided to finish the special like this to avoid losing time changing the tyre."

Spain's reigning champion Carlos Sainz, third in the stage, moved back into the top 10 but more than five hours off the lead.

The seventh stage was also a good one for South Africa’s Giniel de Villiers, who posted the sixth fastest time of the day. He is now in the perfect position to support his team-mate Al Attiyah.

“Our starting position for tomorrow puts us two cars behind Nasser – just 6 minutes in real time. So, if Nasser runs into any difficulties, which we really hope he doesn’t, we’ll be on site very quickly to support our teammate,” said De Villiers.

South Africa’s Shameer Variawa (Red Lined Nissan Navara) made a brave attempt to get back in the running after Sunday’s gearbox maladies, and reportedly finished fifth in his class in Stage 7.

Brabec back in bike race

Ricky Brabec is back in the lead: AP Photo / Ricardo Mazalan.

American Ricky Brabec moved back to the top of the motorcycle category, seven minutes clear of French rider Adrien Van Beveren.

Britain's 2017 Dakar winner Sam Sunderland won the stage.

As for the locals, Botswana’s Ross Branch and South Africa’s Kenny Gilbert, finished the stage 18th and 29th respectively, the pair sitting 17th and 26th overall. No-service crew Original class rider Stuart Gregory is currently in 78th overall.

Tuesday’s eighth stage will see a mixed start, with the top 10 motorbikes, top 10 cars and top five trucks all going off in order of the times they set during Stage 7. This means that Peterhansel will have a number of bikes setting off before and after him.

Sources: Reuters, Motorsport Media, Dakar.com & Toyota SA