Halep reached the final in the Spanish capital last year, but looked out of sorts as a double fault handed Cornet the opening set in a tie-break.
And the Romanian’s serve crumbled when serving to stay in the match in the second as Cornet wrapped up victory in just under two hours on court.
Halep’s exit could be a big boost to defending champion Maria Sharapova who could face Britain’s Heather Watson in the next round.
The five-time Grand Slam winner showed no signs of her recent struggles with form and fitness as she beat Switzerland’s Timea Bacsinszky 6-2 6-3.
Sharapova had been set to met Halep in the last four had both women made it that far.
The Russian dominated the Bacsinszky serve in the first set to break three times and then depended on her own in the second as one break in the eighth game was enough to set up a second round clash with Watson or Colombian Mariana Duque-Marino.