Spain were crowned Davis Cup champions for the sixth time after winning both singles matches in the final against Canada in Madrid.
The home team were looking to secure a first title since 2013, while Canada were seeking a maiden triumph after reaching the final for the first time.
Roberto Bautista Agut sought to give Spain the perfect start at La Caja Mágica when he faced Felix Auger-Aliassime in the first singles match.
The Spaniard, competing just days after the death of his father, was roared on by the local crowd.
He claimed the opening set on a tie-break, before breaking Auger-Aliassime’s serve in the second to eventually secure a 7-6, 6-3 victory.
The result saw the pressure mount further on Denis Shapovalov, who faced the unenviable task of having to end Rafael Nadal’s 31-match winning streak at the Davis Cup.
The world number one’s sole singles defeat in the competition came back in 2004 when he lost to the Czech Republic’s Jiri Novakk.
Spain closed on victory when Nadal won the opening set of the match 6-3 against Shapovalov.
The 20-year-old Canadian forced Nadal into a second set tie-break and saved two match points, but was unable to convert on his own set point.
Nadal ultimately sealed a 6-3, 7-6 victory to maintain his winning record and secure a triumph for the home team without them having to take to the court for the doubles.
"Amazing week, a lot of things we went through," Nadal said.
"The father of Roberto passed away, a lot of things happened.
"I could not be happier.
"It has been an unforgettable moment in this amazing stadium and we can't thank the crowd enough."
Spain have now won the event six times in 19 years.
They had previously triumphed in 2000, 2004, 2008, 2009 and 2011.
They become the first nation to win under the revamped week-long finals format introduced by the International Tennis Federation with their partner Kosmos Tennis – founded by Spanish and Barcelona football star Gerard Pique.
Despite defeat, Canada enjoyed their most successful Davis Cup.
Their previous best performances had been semi-final defeats in 1913 and 2013.