Querrey, seeded No. 24, advanced to his first Grand Slam semifinal in a 3-6, 6-4, 6-7 (4), 6-1, 6-1 victory against the top-seeded Scot on Centre Court at the All England Club in London.
Querrey is the first American man moving into a Grand Slam semifinal since 2009 Wimbledon runner-up Andy Roddick.
"At the end I shocked myself on the serve I hit," Querrey told BBC Sport in a post-match interview. "I didn't start my best, but kept with it and swung away before playing better in the third and fourth sets. It's a dream come true to be in the semifinals. I will enjoy this one for the moment, then I will get ready for Friday's semifinals."
Murray can remain No. 1 in the world rankings if Novak Djokovic does not capture his fourth Wimbledon trophy on Sunday.
"I didn't start my best, but I just kept with it. Kept swinging away and then really found a groove in the fourth and fifth set," Querrey said. "And everything kind of seemed to be falling my way then."
Murray, who had not previously lost to a player ranked as low as the 28th-ranked Querrey in 12 years of competing at the grass-court championship, took a 3-0 lead as his opponent made a nervous start, unsure of his movement and when to attack the net.
The 30-year-old Murray, a two-time champion at the All England Club, entered the tournament after pulling out of two exhibition matches citing a sore left hip.
Querrey silenced the home crowd in the final two sets with Murray limping and appearing to suffer with his movement on court.
Querrey raced to a 3-0 lead in the fifth and broke Murray once again for a 5-1 lead before closing out the match with his 27th ace.
"I think I had chances in the first three sets," Murray said. "The second set, I was up 4-3 and then got broken twice there. That obviously turned out to be an important part of the match. Maybe I could have got the match done in three sets there.
"Sam served extremely well at the end of the match and loosened up and was going for his shots. The whole tournament I've been a little bit sore but I tried my best right to the end. I'm proud about that. There was obviously an opportunity. I'm sad it's over."
Murray was limping between points and fading down the stretch. He was asked to be more specific about his injury.
"I'm not going to go into all the details about exactly what my hip issues are," Murray said. "I've been dealing with it a very long time. As you get older things are harder to manage. There's a bit more wear and tear there. I've managed to deal with it for a very long time. Moving forward I'll be able to get through it. I need to do all the right things and be even more diligent and professional than I have been recently. I feel I've done all the right stuff but I need to do more and come back the other side of it a better player and athlete."
Seven-time Wimbledon champion Roger Federer of Switzerland followed on Centre Court against Canada's Milos Raonic, who beat Federer in last year's semifinals.
In the other quarterfinal match on Court 1, second-seeded Djokovic of Serbia took on No. 11 seed Tomas Berdych of the Czech Republic.