Ten-time champions France made into the final for the second consecutive year, aiming at achieving their title defense against Croatia at home late in November.
Querrey, drafted in by USA captain Jim Courier as a replacement for his number one Steve Johnson, was one set down and saved five straight set points in the second before rallying to earn a shock 6-7 (2) 7-6 (6) 6-3 6-4 win.
Only when 40-year-old Mike Bryan and Ryan Harrison fought courageously to claw out a five-set doubles win on Saturday, were the Americans given even faint hope of contesting the last final to be staged under the traditional Davis Cup format.
Sam Querrey kept the Americans in it on Sunday in the first match, stunning Marin Cilic 6-7 (2), 7-6 (6), 6-3, 6-4. "That's all I can say", the Portuguese umpire told the Associated Press on Friday.
On Sunday, Cilic seemed on his way to a second win in the tie, as he sealed the first set 7-6 (7-2) and had a 6-1 advantage in the second-set tie breaker, just one point away from a two-set lead, but then lost the next seven points and the set.
Croatia's Borna Coric was to face Davis Cup rookie Frances Tiafoe in the decisive fifth rubber.
The victor on an outdoor clay court along the Dalmatian coast will meet either France or Spain in the final.
Bryan and Harrison won a deciding-set tie-break to end a thrilling comeback from Ivan Dodig and Mate Pavic with a 7-5, 7-6 (8/6), 1-6, 6-7 (5/7), 7-6 (7/5) victory after four hours and 43 minutes on court.
World No. 1 Rafael Nadal is Spain's only Top 20 player.
They also faced France in the final of this summer's football World Cup, with Les Bleus winning 4-2.
On hardcourt in France Benoit Paire defeated Spain's Pablo Carreno-Busta 7-5, 6-1, 6-0 in the first singles on Friday.