The World No.1 and defending champion was beaten 6-7 1-6 6-3 6-7 in a pulsating rain-delayed clash on Court 1.
Djokovic became the first man to win four straight grand slam titles since 1969 when he won last month's French Open.
It's the first time the Serb has suffered defeat at a grand slam since the 2015 French Open final, where he was beaten by Stan Wawrinka, a run of 30 straight matches.
Querrey, seeded 28th and ranked 41 in the world, had led by two sets to none when rain forced play to be suspended Friday.
Djokovic fought back to take the third but the American held his nerve to win the fourth on a tiebreak and make history.
"It's incredible, especially to do it here at Wimbledon," Querrey told the BBC.
"I'm so ecstatic, so happy. I think today I played the break points well.
"Every time he had a break point I was able to come up with a big serve.
"He came out and got the first four games, fortunately for me we had another rain delay and I got to regroup."
Querrey will face Frenchman Nicolas Mahut for a place in the quarterfinals, while Djokovic was left to rue lost opportunities after seeing his dream of a calendar grand slam -- last achieved by Rod Laver in 1969 -- shattered.
After taking the third set, the Serbian served for the fourth at 5-4, only to be broken back by an inspired Querrey.
"I had my chances maybe in the fourth set, serving for the set. In the tiebreak, I was leading. Just wasn't feeling the ball as well as I wished. But that's sport," Djokovic told reporters.
"It's disappointing, of course. Losing at a grand slam hurts more than any other tournament."
There were hints at the press conference that Djokovic may not have been 100 percent fit, "I don't want to talk about it" he said, but he confirmed he would not be playing for Serbia in its quarterfinal Davis Cup tie against holders Great Britain later this month.
World number two and home favorite Andy Murray was playing on Centre Court as Djokovic slipped to defeat and he made no mistake with a 6-3 7-5 6-2 third round win over Australia's John Milman.
Murray has been beaten by Djokovic in the finals of the last two grand slams and will now play Australian 15th seed Nick Kyrgios, who beat Spain's Feliciano Lopez in a match completed Sunday.
His path to Wimbledon glory has certainly been eased by Querrey, who is only the fourth-ranked American and among non-tennis fans is best known for an unsuccessful appearance on the TV dating show, Millionaire Matchmaker.
Querrey also contested the second longest men's singles match in Wimbledon history, losing in the third round to Marin Cilic in a five and a half hour match in 2012.
Croatia's Cilic also made it to the fourth round Saturday, as did Querrey's fellow Californian Steve Johnson, who put out Grigor Dimitrov of Bulgaria in four sets.
But Jack Sock was unable to complete a hat-trick of U.S. victories, beaten by sixth seed Milos Raonic of Canada.
In the women's singles, there was another big upset as two-time champion Petra Kvitova crashed out of Wimbledon, losing 7-5 7-6 to Russia's Ekaterina Makarova in the last second round match to be completed.
The Czech, who was champion in 2011 and 2014, made a string of unforced errors, 43 in all, to hasten her exit, but complained about the delays that had left her with under three hours of court time over six days.
"It's very weird, I have to say. I felt like I was stuck in the second round," said Kvitova.
But there was an impressive third round victory for Romania's Simona Halep over Kiki Bertens of the Netherlands, while Australian Open champion Angelique Kerber also went through against fellow German Carina Witthoeft.
Halep will play emerging 19-year-old American Madison Keys Monday for a place in the quarterfinals.
2014 finalist Eugenie Bouchard of Canada also departed at the third round stage,
beaten 6-4 6-3 by Slovakia's 18th seed Dominika Cibulkova.
Organizers were playing catch up Saturday after rain has disrupted the tournament, meaning play will take place on the middle Sunday for the first time since 2004.