Krejcikova into Wimbledon semi-finals after grim run
Krejcikova, the 31st seed, won 6-4, 7-6 (7/4) and will face 2022 champion Elena Rybakina for a place in Saturday's final.
"I told myself that I'm going to leave here everything I have and I'm really happy that I did and it's a great moment for me," said Krejcikova, who saw Ostapenko undone by 35 unforced errors.
"It's an unbelievable moment that I'm experiencing right now in my tennis career."
Victory for the 28-year-old Krejcikova comes after a miserable run in 2024.
She was off tour for two months with a back injury and then illness.
Her run to the Birmingham quarter-final last month allowed her to celebrate match wins for the first time since Abu Dhabi in February.
"It was a very, very difficult period. It was actually super difficult even before this tournament. I really want to thank my team that is there today," said Krejcikova.
"There have been many doubts from inside but also from the outside world but I'm super happy that I never give up and that I'm standing here right now and that I qualified to be in the semi-finals."
On Wednesday, Krejcikova claimed the only break of the opening set to lead 2-1 and swept ahead on the back of winning 95 percent of first-serve points.
Ostapenko had defeated Krejcikova in the Birmingham grass-court final last season but was unable to carve out a single break point against the Czech in the first set.
The 2018 Wimbledon semi-finalist finally broke through in the fourth game of the second set for a 3-1 lead and backed it up with a hold.
However, the 13th-seeded Latvian went dramatically off the boil as Krejcikova reeled off the next four games for a 5-4 lead.
Ostapenko clung on to break the Czech in the 10th game but 2021 French Open champion Krejcikova played the more composed tie-break to seal the victory.