The 51-year-old, who won the event in 2011, 2015, and 2019, finished ahead of Sebastien Loeb, the nine-time world rally champion from France.
Al-Attiyah, a 2012 London Olympics bronze medalist in skeet shooting, led the race from start to finish.
Sam Sunderland, a British motorbike racer, had won the Dakar Rally for the second time earlier on Friday.
The Dakar Rally began in 1978 as a race from Paris to Dakar, Senegal, but was relocated to South America in 2009 due to security concerns.
One of motorsport’s most dangerous and grueling events, the rally moved to Saudi Arabia in 2020 and is now in its 44th edition.
Earlier this month, France considered cancelling the Dakar Rally after an explosion that badly injured a French driver.
French prosecutors said they opened a terror attack probe over a December 30 blast targeting a car in Jeddah, which left 61-year-old driver Philippe Boutron needing surgery for serious leg injuries before he returned to France.
“We thought that maybe it’s best to abandon this sporting event, the question remains open,” Foreign Minister Jean-Yves Le Drian told BFM television, adding that “there was potentially a terror attack against The Dakar”.
All five occupants of the car, including the driver, were French.
One of the passengers, driver Thierry Richard, told the AFP news agency that he had no doubt that the car was targeted deliberately.
“It was an attack, they blew us up,” he said, adding that the incident had felt “like something from a war scene”.
The impact of the blast lifted the car off the ground and it immediately caught fire, Richard said.
“We’re not stupid, we know what an explosion feels like,” he said.