For another two days, at least, Williams' quest for an Open era record of 23 Grand Slam singles titles, a record seventh US Open title and a new mark for consecutive weeks (187) at No. 1 remains alive.
The match, which captivated the near-capacity crowd at Arthur Ashe Stadium, required 2 hours, 14 minutes to complete.
"I knew I could play a lot better," Williams said during her on-court interview, in reference to her performance in the second set. "I felt I lost my rhythm, and Simona started playing better.
"I knew I had to step it up in the third set."
Williams, the No. 1 seed, faces No. 10 seed Karolina Pliskova in a Thursday night semifinal that will feature the two women with the most aces among WTA players.
It was Serena's 309th major match win, two more than Roger Federer, extending her all-time Open era record.
Halep, a 24-year-old from Romania who is more than a decade younger than Williams, saved all 11 break points she faced on her serve in a heroic second set, but she faded badly in the third. It was, nonetheless, the first time Serena had been challenged this fortnight.
"I wasn't very happy about that, but I tried not to let that get me down,'' Williams said about all the chances she let slip away. "I tried to stay positive and I knew that if I did, I could just stay in the match.''
For the match, Williams could convert only four of 20 break opportunities, but she converted the only break chance she would need in the deciding set to go ahead 3-1.
"It was tough. Is tough,'' Halep said. "I'm a little bit sad.''
Williams finished with 18 aces, a 50-20 edge in total winners and won the point on 26 of her 32 trips to the net.
Information from The Associated Press was used in this report.
Serena gets tested, fights off Halep in three sets
Serena Williams drops her first set of the tournament, but is able to regroup and fight off Simona Halep to advance to the semifinals of the US Open.