Nadal guided Spain to a 2-1 comeback victory over Argentina, while Djokovic couldn't prevent Serbia from being eliminated after a 2-1 loss to Russia.
Andy Murray didn't play again on Friday, but Britain made the last four by beating Germany 2-0.
Spain will make its second straight semifinal appearance after Nadal and Marcel Granollers defeated Máximo González and Leonardo Mayer 6-4, 4-6, 6-3 in the decisive doubles match in front of a lively and vocal crowd at the Caja Mágica center court.
Guido Pella had defeated Pablo Carreño Busta 6-7 (3), 7-6 (4), 6-1 in the first singles, but Nadal had kept Spain in contention with an easy 6-1, 6-2 win over Diego Schwartzman for his 27th straight Davis Cup singles victory.
"It was a must-win match, nothing else mattered," the top-ranked Nadal said.
Argentina, backed by a boisterous group of fans that at times made more noise than the local Spanish crowd, was hoping to get some payback after it was beaten at home by Spain in the 2008 Davis Cup final, when it was heavily favored against a Spanish team that was without an injured Rafael Nadal. Spain also beat Argentina in the 2011 final played in Sevilla.
Argentina made the semifinals for the last time in 2016, when it won its only Davis Cup title.
SERBIA FALLS
Djokovic defeated Karen Khachanov 6-3, 6-3 to even the score at 1-1, then returned to the court about half an hour later to team with Viktor Troicki in the decisive doubles. They had three match points but lost to Khachanov and Andrey Rublev 4-6, 6-4, 7-6 (8).
"It hurts really badly," Djokovic said. "These kinds of matches happen once in maybe forever. That's it. The season is done and we're turning the next page."
The Russians converted on their first match point to put the team back in the Davis Cup semifinals for the first time since 2008.
"Both teams had a lot of chances," said Rublev, who won the opening singles against Filip Krajinovic 6-1, 6-2. "It was like a coin toss, and we won this coin toss."
Russia will next face Canada, which eliminated Australia on Thursday.
Serbia, the 2010 Davis Cup champion, was trying to return to the semifinals for the first time since 2017, when the team lost to eventual champion France.
After his 15th straight Davis Cup singles victory, Djokovic struggled in the doubles, although it was Troicki who squandered most of the chances in the tight tiebreaker, including some during the match points.
"I probably feel the worst ever," Troicki said. "I never experienced such a moment in my career, in my life. And I let my team down, and I apologize to them."
Djokovic, who hadn't played in the Davis Cup since 2017, couldn't hide his frustration as Serbia trailed in the second set, complaining with the umpire and hitting a ball deep into the stands after losing a point. He also requested medical assistance on his right arm.
Serbia was trying to reach the last four for the fourth time since winning its only Davis Cup title in 2010. It was runner-up once since then, in 2013.
BRITAIN ADVANCES
Britain advanced past Germany thanks to Kyle Edmund's 6-3, 7-5 win over Philipp Kohlschreiber and Daniel Evans' 7-6 (6), 3-6, 7-6 (2) victory over Jan-Lennard Struff.
For the second day in a row, captain Leon Smith did not play Murray who, after a comeback victory in the first tie of the group stage, said he was not in his best shape.
"Made the decision last night after talking to the guys," Smith said. "He could play, but I wouldn't say he's in his best condition, as he said to you guys the other day. He says that's how he's feeling. So we have to keep talking about it."
Britain last played in the semifinals in 2016, a year after winning its 10th title.