The fourth stage of the event was run between the cities of Neom and Al-ʿUla, and was led by three different riders before Sunderland snatched the top spot right at the end.
Brabec carried on his strong form from Stage 3 to lead early on despite opening the road, but lost around three minutes at the halfway point as KTM's Toby Price and then Honda rider Kevin Benavides moved ahead.
Benavides had a gap of 1m48s over Cornejo at the 346km checkpoint, but the latter was able to outpace him at the end to provisionally top the classification.
But Sunderland, who was nearly two minutes off at the last checkpoint, was able to narrowly beat Cornejo as well and win by 11 seconds.
Benavides in the end settled for third, with Ross Branch and Paulo Goncalves making up the top five. Branch had crashed the day before, whereas Goncalves suffered engine woes on his Hero bike and was on the cusp of retiring, only finishing that stage seven-and-a-half hours late.
Yamaha's troublesome event continued with more woes after Adrien van Beveren's Dakar ended in a crash on Stage 3.
His teammate Xavier de Soultrait also had an incident on the same day and his attempt to continue with an injured wrist on Wednesday lasted only 300 kilometres before he was forced to withdraw.
Franco Caimi stepped up as Yamaha's main rider and was sixth in the stage, narrowly beating Brabec and Price.
Honda's Joan Barreda had a crash and was 17 minutes slower than Sunderland, while KTM's Matthias Walkner had an even worse day, crossing the line 24 minutes off the pace.
In the overall order, Brabec still leads but by 2m30s only, with Benavides and Cornejo completing an all-Honda top three.
Price and Sunderland are the top KTMs in fourth and fifth as Walkner dropped down to ninth place.
Casale back to winning ways
Having been beaten to Stage 3 victory by Giovanni Enrico, Ignacio Casale fought back to top Stage 4.
Casale was challenged by Enrico and Simon Vitse, both of them taking the lead at one point, but it was the two-time champion who was fastest at the end of the stage.
Enrico completed a Chilean 1-2 and moved into second place in the overall order as well, but his deficit to Casale is 21 minutes.
Vitse was third and he is in the same position in the general standings as well, having demoted Rafael Sonik, who managed only sixth in the stage.