But she eventually held serve in a game that featured six deuces, and then broke back to make it 4-3.
Seventh-seed Halep will now face either number eight seed Elina Svitolina or unseeded Karolina Muchova as she bids to reach the final for the first time having lost to Eugenie Bouchard in the last four in 2014.
Zhang Shuai competes during the women's singles fourth round match between Zhang Shuai of China and Dayana Yastremska of Ukraine at the 2019 Wimbledon Tennis Championships in London, Britain, July 8, 2019.
She later won the first set in a tiebreak, winning five of the last seven points to claim her first set from Zhang in seven years, and eased through the second set behind a pair of late service breaks.
"My plan always is to reach the final stages at Grand Slams", said Djokovic, who is bidding to win his fifth Wimbledon trophy. That looked set to be 5-1 but Halep battled and chased to save four break points in the game and turn the match. Beyond grateful for this last 4 years.
The high-class and gruelling rallies required to do so appeared to play the 2018 French Open champion into form and Zhang coughed up a break in the next game with a double fault. "She is a little more aggressive than she has been, her serve is a bigger weapon - Zhang could be the ideal draw on paper, but at the same time, Halep simply has to win and the pressure is on her". "It's a big draw for Simona and she could have a good chance to go through". After beating teenage sensation Coco Gauff in straight sets, Halep will take on Zhang Shuai of China in the quarterfinals.
Halep brought an end to Cori Gauff's incredible Wimbledon journey on Monday.