Nadal’s win gave Spain an insurmountable lead and a place in the quarterfinals, before David Ferrer beat Viktor Troicki 6-0, 6-3 in the meaningless last singles match to round off a 4-1 win.
The third-ranked Djokovic struggled with his serve and unforced errors on the outdoor clay at the Terra Mitica amusement park as Spain clinched its 15th straight home tie.
Spain, which failed to advance from the first round as defending champion in 2001 and 2005, will welcome the winner of Germany-Austria in July. Serbia lost in the first round for the second straight year and will play in the World Group playoff.
“For various factors, it wasn’t good for us, it wasn’t nice to lose the way we did,” Djokovic said. “We just have to hope for the best draw come September.”
Nadal, the top-ranked player and four-time French champion, won for the 121st time in his last 124 matches on clay as he made a spotless return to the court after injuring his right leg at Rotterdam last month. On Saturday, Nadal routed Janko Tipsarevic to put Spain up 2-0.
The 22-year-old Nadal joined his Spanish teammates in the stands to celebrate alongside a crowd of 14,000 after the victory, which improved his overall Davis Cup record to 11-1.
“The surface favored me, the ball was jumping high. I felt comfortable and he committed more errors than usual,” Nadal said.
Nadal, who improved his overall record to 11-4 against the Serb including 6-0 on clay, brushed off suggestions that Djokovic’s form had been poor this season.
“We’ve had two months of competition and he won Dubai, one of the biggest tournaments. I don’t see any problem,” Nadal said. “He always plays at a high level.”
Serbia’s only point came from doubles on Saturday, when Nenad Zimonjic and Troicki beat Tommy Robredo and Feliciano Lopez 7-6 (5), 6-4, 7-6 (7).
ALSO ON THIS STORY
Discuss: Sound off on tennis at Newsvine.com
Also on NBCSports.com
NFL: Crazy as it sounds, Bills take smart gamble
NBA: Home sweet home has its advantages | Images
Baseball: Manny's a knucklehead, but game needs him
College hoops: Big Dance could've used high-scoring VMI
College football: No rest in Red River Rivalry