Halep was the two-time defending champion and on a 15-match winning streak at the clay-court tournament. But Pliskova gave the Romanian no chance, breaking her serve four times and hitting 20 winners.
"I think I played one of my best matches this year for sure, and for sure on clay in my life," the sixth-seeded Pliskova said. "I feel amazing, since in the last six matches I lost to her. I never thought I would beat her. My serve was great and everything went my way."
Halep got off to a great start by breaking Pliskova for a 2-0 lead, only for the Czech to take the break right back to swing the match in her favor.
"I missed in some important moments. That's why it went her way," Halep said. "I'm not upset. I'm not looking in a negative way. I won two times here. I played great matches. So I take the positives."
Pliskova's only prior victory from her previous seven matches against Halep was in the 2016 Fed Cup.
Pliskova arrived in Madrid fresh from winning her 10th career title in April, when she was victorious on clay in Stuttgart, Germany.
She is now the highest-seeded player left in the women's tournament after No. 2 Caroline Wozniacki and third-seeded Garbine Muguruza lost Wednesday. Pliskova beat Victoria Azarenka and Sloane Stephens in previous rounds and has recorded nine wins in a row.
Garcia will take on Bertens, who came from behind to beat Sharapova 4-6, 6-2, 6-3. Bertens finished Sharapova off when the Russian's backhand missed on a second match point.
In the third round of the men's tournament, Dusan Lajovic fought back from 0-4 in the decisive tiebreaker to stun fourth-seeded Juan Martin del Potro 3-6, 6-4, 7-6 (6) for his first career win against a top-10 ranked player.