The world number one, bidding for a fourth Wimbledon title and 13th major, suffered his earliest loss at a Slam since the 2009 French Open.
The 7-6 (8/6), 6-1, 3-6, 7-6 (7/5) third round defeat also ended Djokovic’s Open era record run of 30 successive wins at the majors and his streak of having reached 28 consecutive Grand Slam quarter-finals.
“Sam played a great match. His game was brutal and I was overpowered,” said the Serb, who added that he “wasn’t 100 percent healthy”.
Djokovic, who completed a career Grand Slam at the French Open, refused to dwell on failing to become the first man since Rod Laver in 1969 to win a calendar Grand Slam having won in Melbourne and Paris already this year.
“I managed to win four Grand Slams in a row. I want to try to focus on that rather than on failure,” he added.
“Coming into Wimbledon, I knew that mentally it’s not going to be easy to kind of remotivate myself.”
Djokovic added that he would not be playing in the Davis Cup quarter-final against Andy Murray’s Great Britain in Belgrade in two weeks’ time.
America’s Querrey, the world number 41, built only his second win in 10 meetings with Djokovic on an epic-serving performance over two days after the tie had been suspended with him two sets to the good on Friday.
The 28-year-old sent down 31 aces — 15 in the fourth set alone — and saved 14 of 17 break points while unleashing 56 winners.
His reward is a last-16 clash with 34-year-old Frenchman Nicolas Mahut.
“It’s incredible, especially to do it here at Wimbledon. I’m so ecstatic right now and so happy,” said Querrey.
Rain had saved 29-year-old Djokovic on Friday. On the resumption Saturday, the US, Australian and French Open champion took the third set 6-3.
In the fourth, he squandered 11 break points before finally breaking through at the 12th time of asking for a 5-4 lead.
But he couldn’t convert with the American hitting straight back for 5-5 and holding for 6-5 when the rain returned to cause a second suspension of the day on Court One.
Djokovic served to take the set into the tiebreak and was ahead at 2/0 and 4/3 but Querrey clawed his way to two match points.
The top seed saved the first, but ballooned a forehand wide and his fate was sealed.
Murray cruises through
Djokovic’s defeat was good news for second seed Murray who lost to his long-time rival in the Australian and French Open finals this year.
The 2013 champion responded by making the last-16 with a 6-3, 7-5, 6-2 victory over Australia’s John Millman under the Centre Court roof.
“What Novak’s done in the last 18 months, I don’t think we’ll see again for a long time. The level of consistency he’s had is amazing, but it’s impossible to win every match,” said Murray.
Murray will play Australian 15th seed Nick Kyrgios or Spain’s Feliciano Lopez for a place in the quarter-finals.
That tie was suspended due to bad light at one set apiece.
Japanese fifth seed Kei Nishikori beat Andrey Kuznetsov 7-5, 6-3, 7-5 to set up a last-16 clash with Marin Cilic, the Croatian ninth seed who eased past Lukas Lacko of Slovakia 6-3, 6-3, 6-4.
That will be a repeat of the 2014 US Open final won by Cilic.
In-form American Steve Johnson reached the fourth round of a major for the first time by defeating former semi-finalist Grigor Dimitrov of Bulgaria 6-7 (6/8), 7-6 (7/3), 6-4, 6-2.
The world number 29 faces seven-time champion Roger Federer for a place in the last-eight.
Canadian sixth seed Milos Raonic, a 2014 semi-finalist, defeated America’s Jack Sock 7-6 (7/2), 6-4, 7-6 (7/1) and next faces Belgium’s David Goffin.
Due to the rain-hit first week, two-time champion Petra Kvitova only finished her second round match at 5:30pm (1630 GMT).
The Czech 10th seed, with 43 unforced errors, lost 7-5, 7-6 (7/5) to Russia’s Ekaterina Makarova.
Third seed Agnieszka Radwanska, the 2012 runner-up, enjoyed a 6-3, 6-1 win over Katerina Siniakova and next plays Dominika Cibulkova, the 19th seed from Slovakia.
German fourth seed and Australian Open champion Angelique Kerber also reached the last-16 with a 7-6 (13/11), 6-1 win over compatriot Carian Witthoeft.
A semi-finalist in 2012, Kerber will next face Japan’s Misaki Doi.