Brazil were competing in their seventh successive FIFA Beach Soccer World Cup semi-final, having also played in five previous finals.
Spain in contrast were featuring in only their second semi-final, having done so in 2008 when they lost to Italy on penalties.
A tense match remained devoid of major goalmouth action during the first period, although Bruno Xavier broke the deadlock with an opportunistic finish at the back post.
Juanma drew Spain level in the latter stages of the second period with a snapshot from an acute angle as the Europeans found their way back into the contest.
The second period picked up in the dying stages with both goalkeepers seriously tested.
Brazil turned up the heat in the third period hitting the post twice within a minute, and looked the more likely to find a winner as the clock wound down.
Extra time came and it was Spain that broke the deadlock with more than a slice of luck, and with just two minutes, 32 seconds remaining on the clock.
A low shot from captain Nico bounced in front of the goalkeeper, reared over his head off the underside of the bar and just over the line.