Townsend's dramatic week has been one of the stories of the tournament so far, with the American becoming headline news after her second-round opponent Jelena Ostapenko confronted her courtside and accused her of having no education and no class.
A storm ensued over whether the comments were racist - Ostapenko insisted they were not and later apologised - and Townsend used the incident as inspiration to claim one of her biggest career wins over fifth seed Mirra Andreeva as she received huge crowd support.
With her four-year-old son AJ in the crowd, Townsend looked set to reach a singles grand slam quarter-final for the first time but former Wimbledon champion Krejcikova somehow prevailed in a titanic second-set tie-break before clinching a 1-6 7-6 (13) 6-3 victory.
Townsend left the court in tears with a towel over her face to cheers from the packed stands on Louis Armstrong Stadium who had roared her on.
It was Krejcikova who had been in tears on court at Wimbledon in what has been a very difficult season for the Czech because of injury.
She struggled to contain her emotions as she said to the crowd: "What a match. Just four months ago I was off the court, I couldn't play. I had a huge pain in my back. I didn't know if I'll ever be back. Now here I am and this is huge. I still cannot believe that I'm standing here."
Townsend dominated the opening set and looked poised to win the second as well, with Krejcikova saving her first match point in the 10th game.
It was the tie-break that really saw the 29-year-old pull off her Houdini act, though, Krejcikova saving her best for when it really mattered to fight off seven more match points, recovering from 3-6 before taking her third set point.
The Czech then took an off-court break, leaving Townsend sat on her chair wondering what might have been, and it was Krejcikova who had the momentum in the deciding set.
She next faces another American in fourth seed Jessica Pegula, who lost in the final last year and breezed through to the last eight again with a 6-1 6-2 victory against Ann Li.
Pegula has turned around a rough stretch herself, having crashed out in the first round of Wimbledon before suffering early exits in Washington, Montreal and Cincinnati, casting a pall over her latest Flushing Meadows campaign.
But the 2024 runner-up has found another gear at Arthur Ashe Stadium, where she has yet to drop a set through four rounds.
"I felt terrible coming into this tournament, honestly. I had a practice Wednesday, I think I hit with (top seed Aryna) Sabalenka. She killed me. I was playing terrible," said Pegula.
- with The AP