The world number two had cruised into the last eight but was taken the distance by Jo-Wilfried Tsonga before coming through 7-6 (12/10) 6-1 3-6 4-6 6-1 after three hours and 53 minutes.
Murray has made a habit of fighting back from two sets down but this time it was Tsonga threatening to do the improbable.
Yet Murray has only ever lost once having won the first two sets and, after telling his box he was not going to lose this one, he delivered superbly to set up a last-four clash with Tomas Berdych, who beat France’s Lucas Pouille (Fra) 7-6 (7-4) 6-3 6-2.
Murray said: “Obviously it was a tough match. The end of the fourth set was really tough.
“I tried to use all my energy at the beginning of the fifth set to get myself up and get the crowd pumped up.
“Thankfully I got the early break and I hung on to it.”
Asked about letting his lead be whittled away, Murray said on BBC One: “Tsonga’s a pretty good player, he’s not bad, he’s one of the best grass-court players in the world. He came up with some great shots.
“He started returning better and mixed it up well. Credit to him for fighting his way back into the match.
“He fought really hard until the end.”
Murray was thrilled with the way he handled the decider, and added: “I’m happy I’m through to the semis, it’s time to go and rest and get ready for the next one.”
Meanwhile Roger Federer believes his stunning five-set escape against Marin Cilic proves he has the stamina to win a record eighth Wimbledon title.
Federer saved three match points and battled back from two sets down on Centre Court to beat Cilic 6-7 (4/7) 4-6 6-3 7-6 (11/9) 6-3 in the contest of the tournament so far.
It means the Swiss is now two wins away from overtaking Pete Sampras’ seven Wimbledon triumphs and he will now play Canada’s Milos Raonic for the chance to seal his 18th grand slam title. At 34 years and 336 days, Federer is the oldest man since 1974 to make the last four at this tournament and his resilient victory sends a clear message to those doubting his staying power.
“What I like about being in a fifth set is you actually get really tested to see where your fitness is and where your mind is at,” Federer said.
“Can your shoulder, your back, your legs, sustain three hours 17 minutes of just hitting big serves, running, being explosive?
“Can I handle it?
“That’s why I was very intrigued, pushing myself a lot in the fifth to get over the finish line, because I was feeling as good at the end as I was in the beginning.
“That gives me a lot of confidence moving forward from here. I feel like I’ve clearly got a chance in the semis, even after a match like this.”
Milos Raonic will face Federer after he ended Sam Querrey’s impressive trip to his first Grand Slam quarter-final, serving and volleying his way to a 6-4, 7-5, 5-7, 6-4 win in two and a half hours.
(1) Serena Williams (USA) v Elena Vesnina (Rus), (4) Angelique Kerber (Ger) v (8) Venus Williams (USA), (1) Pierre-Hugues Herbert (Fra) & Nicolas Mahut (Fra) v (12) Treat Huey (Phi) & Max Mirnyi (Blr)