Spain beat Hungary in a thrilling men's final in which they won the first set 23:22 before Hungary responded in the second, winning 24:25.
A suitably nail-biting shoot-out followed, which was edged 13:12 by Spain to take gold and force Hungary to settle for silver.
Spain began the three-day tournament with a defeat to Norway, before beating Poland and Denmark to reach the quarter-finals.
They needed shoot-out wins over Germany and Denmark in the knockout stages to reach the final and that experience paid dividends in the final.
The bronze medals went to Denmark, who beat Portugal in the third place match.
Spain's women were on the losing side of a shoot-out in their final, going down 10:8 to Denmark.
Denmark had won the first set 22:20, before Spain won the second, 21:20.
The Danes beat Portugal in the quarter-finals and Germany in the semis without dropping a set, having also beaten Spain in the preliminary round. First stage wins over Poland and Norway meant they finish the competition unbeaten.
Bronze went to Germany, who took a 2:0 win over Norway.