Spain staved off elimination as Marcel Granollers and Marc Lopez came back to beat Canada's Daniel Nestor and Vasek Pospisil in doubles action.
After trailing 1-0 and 2-1 in sets, Granollers and Lopez rallied to win 4-6, 6-4, 6-7 (4), 6-3, 6-2. The physically-punishing match lasted three hours 54 minutes at UBC's Doug Mitchell Thunderbird Sports Centre.
"We did the best we could with how we were feeling," said a tired Pospisil.
The loss denied Canada a historic upset sweep of five-time champion Spain.
Canada is attempting to advance to the second round of Davis Cup World Group play for the first time.
"We still have the best chance of winning," said Pospisil. "We were not too far from closing the deal today, but we have two strong singles guys going for us (Sunday), and the whole team's feeling really good, really confident.
"We're one match away from making a historic run."
The Spaniards, who are missing their top stars to injury and rest, now trail the best-of-five tie 2-1.
"(Down 1-0 in sets) we were still fighting for the sets," said Granollers. "And, finally, we found a way to win."
Nestor did not attend a Canadian team post-match news conference for health reasons.
"He's not feeling very good at the moment," said Canadian captain Martin Laurendeau. "It isn't anything super-serious, but he's just not in shape to come up here and share the match with you."
Laurendeau said the team doctor was examining Nestor.
Frank Dancevic of Niagara Falls, Ont., and Milos Raonic of Thornhill, Ont., staked Canada to a 2-0 lead in singles play Friday.
David Ferrer, ranked fourth in the world, Rafael Nadal (fifth), Nicolas Almagro (11th) and Fernando Verdasco (24th) stayed home. While Nadal and Almagro are out with injuries, Ferrer and Verdasco chose to rest.
Granollers and Lopez captured the ATP World Tour doubles title, while Nestor and Pospisil have had fleeting success together in Davis Cup and Olympic play. But in the early going, the Canadians were able to capitalize on several mistakes by Granollers, who was upset by unheralded Dancevic, ranked 166th in the world, in singles action Friday.
With Spain missing its top stars, Granollers was tagged as Spain's top singles player for this event. He struggled early, shaking his head a number of times at his disappointment and, at one point, throwing his racket on the court in disgust.
But Lopez remained steady throughout the match and helped Spain get through its difficulties.
"We played really well to be able to change, and we had a lot of confidence to be able to win," said Lopez.
Nestor, from Toronto, made key shots to give Canada the first set win. And, following a close loss in the second set, helped the Canadians jump out to a 3-0 lead in the third. But Spaniards were able to rally and, despite losing the set on a tiebreaker, did not let the setback get to them. They took the next set with surprising ease and maintained momentum, which they had lacked earlier, until the end.
Spain captain Alex Corretja said the gruelling tiebreaker helped his players, who displayed better fitness as the match extended beyond three hours. Corretja declined to divulge what he said to Lopez, 30, and Granollers, 26, after they trailed following the first and third sets.
"I think I will keep it to them," said Corretja. "They played very well. They had so many chances. They were having so many break points. They were very close to have the Canadian team, but it looked like we never reached that point.
"Every time we got closer, then we got far again. As soon as we lost the first set, I told them to keep on fighting. I though they were a better team and, physically, I thought they were a much fresher team."
Vancouver's Pospisil, 22, recuperating from a bout of mononucleosis, showed more visible fatigue than Nestor. But the veteran, who had staged an extensive mid-week practice session in anticipation of a long match, also showed signs of fatigue as he began to miss more shots and struggled to get to the ball.
Laurendeau said Nestor was feeling lightheaded and dizzy.
"He just told me that he started feeling not so good in the fourth (set) and carried on," said Laurendeau. "He tried to hang on."
Laurendeau praised Pospisil for battling hard after making a quick recovery.
"Speaking honestly, for sure, there was little issues — not in terms of strength," said Pospisil. "But my legs were getting heavy, which is to be expected, obviously, going five sets. So I was trying to save some energy, some mental energy, with the crowd as much as I could.
"But they didn't really give us any openings. They pretty much shut the door on us there. Their level didn't drop at all throughout the whole match. We did the best we could with what we had."
Sunday's closing singles matches comprise reverse rubbers as the teams alternate opening-day opponents. Raonic, ranked 15th in the world, will play Granollers, ranked 34th, in the first, potentially, decisive match, while Dancevic is slated to play Albert Ramos (51st.)
"We have our No. 1 going into the first match, being up 2-1, and (Raonic) revels in this kind of a limelight," said Laurendeau. "He's being put on the stage and, throughout his career, when he's playing on centre courts in Davis Cup, he seems to rise.
"So that's what we're counting on."
Note: If Raonic wins in straight sets, the second match will go ahead as scheduled. If Raonic wins in four or five sets, the captains will have the option of cancelling the last match. ... Spain has never won a Davis Cup tie after trailing 2-0. ... Attendance was 5,889, down slightly from Friday.