Nearest rival Marc Coma, who suffered a gearbox problem on Saturday, completed the final 29km special on the stage between Pisco and Lima in Peru in a time of 23 minutes 29 seconds.
France's Despres, also on a KTM, was 2:27 off his pace to seal his fourth overall victory in the world-famous endurance rally. He also won it in 2005, 2007 and 2010.
Portuguese Helder Rodrigues completed the podium after finishing eighth on the stage, 3:41 behind its Norwegian winner Pal Anders Ullevalseter, whose time was 22:26.
Spaniard Coma was second on the stage, 1:08 back from Rodrigues, while Despres was 10th. Stefan Svitko of Slovakia was third on the day.
"I like doing my homework and, in my job, when things go OK you end up winning," said Despres.
"Today we won and it's simply fantastic. This is without a shadow of a doubt the toughest Dakar I've ever raced in. It was difficult physically, but even more psychologically. Challenging yourself every morning and fighting on the course takes its toll on your mind. It's not like a 42-kilometre marathon; here, you have to earn your place every morning.
"All victories are beautiful, but this one is special because it came down to the wire and was decided at the last minute. This was an unimaginable scenario, with the leaders separated by mere seconds.
"I've done 90 or 85 rallies throughout my life, and this one was the one where I had to fight the hardest. Today will leave its mark on me."
Coma immediately started thinking about next year's race.
"I finished second in what was a difficult rally. I gave it my all every single day. I wish to congratulate Cyril. He's the champion. But I'm going to work hard to try and win again next year. If we keep alternating... it should be my turn! But first I have to work," he said.
Rodrigues was delighted to join the two Dakar legends on the podium.
"Making it to the end of a Dakar is always terrific. So finishing on the podium is simply incredible. There are two great riders, Marc and Cyril, and they're tough nuts to crack," he said.
"I lost 20 minutes in stage 4 and 20 more two days later. I was 40 minutes back, so I knew catching up with them would be hard.
"Winning the Dakar requires perfect preparation all year round and making sure everything goes well during the race. I'll try and find the solution to be as good as they are. I need a bit more of everything, especially money to build a strong structure."