Querrey was coasting at 2-1 up with a break in the fourth, but Ward fought back to complete one of the greatest performances in Great Britain's Davis Cup history to win 1-6 7-6 3-6 6-4 6-1.
© Getty Images
The writing looked on the wall for the world number 175 as he lost the opener in 25 minutes, but he dug in during a close second set to take it on a tie-break.
The big-serving American restored normal order in the third, and after establishing a 4-2 advantage in the fourth set and having not lost serve in the match, he looked on course for a routine triumph.
However, Ward struck back to level the set and match as Querrey wilted, before the Brit produced an inspired deciding set to dominate an opponent ranked 130 places above him to reward the team's supporters who had made the long journey to San Diego.
Earlier in the day, Andy Murray lost just six games as he eased to a 6-1 6-2 6-3 against Donald Young, and after Ward's success, Great Britain require just one victory to progress through to the quarter-finals.