The Spanish pair of Scott Fernandez and Pedro Oriol had to go to the 18th green to beat Icelanders Birgir Hafthorsson and Axel Boasson by two holes to clinch the gold medal.
"Before playing this tournament, Scott (Fernandez) and myself were talking about the gold medal and we did it," Oriol said. "It's an honour to play for Spain. It's an honour to win a gold medal for Spain. I'm actually a little choked up."
The women's team final was an even closer encounter, with Sweden's Cajsa Persson and Linda Wessberg winning on the second of two sudden play-off holes against French duo Justine Dreher and Manon Molle.
Although they were the lowest ranked of Sweden's three teams, they had a strong belief that the gold medal would be theirs.
"I called her (Cajsa) a week ago and said 'we can win this'," Wessberg said. "It was just a good feeling and it paid off."
Italian pair Francesco Laporta and Alessandro Tadini were the men's bronze medallists after beating Spain's Santiago Tarrio Ben and David Borda 5&3.
The women's bronze medals went to British number three team Meghan MacLaren and Michelle Thomson, who started as the underdogs against the top British pair Laura Davies and Georgia Hall before winning 3&1. It gave them their second medal after winning the silver in Saturday's mixed team event.
Iceland had already made sporting history with their quartet of Valdis Thora Jonsdottir, Hafthorsson, Olafia Kristinsdottir and Boasson, who surprised the golfing world by winning the inaugural mixed team gold.
They also made a separate piece of history by winning Iceland's first medal of the Glasgow 2018 European Championships. The achievement was even more impressive given the limited opportunities they have to play golf.
"There are only five months when we can play because of the weather," Kristinsdottir said. "Icelanders are from a really small nation, but we have really big hearts and we believe we can do anything. That is why we have succeeded in so many areas. It is special to put golf on the map."
The silver medal went to British number three team MacLaren, Liam Johnston, Thomson and Connor Syme, while Sweden's second team quartet of Johanna Gustavsson, Oscar Floren, Julia Engstrom and Daniel Jennevret took the bronze.