Sweden knew before their victory over Switzerland in the last Main Round match that they would be destined to miss the semi-finals and instead battle for a top-five place. Portugal arguably had more to play for, as a win would ensure their highest finish at a European Championship.
A Martim Costa goal in the third minute put real daylight between the two sides for the first time, as Portugal led 3-1. Antonio Areia extended the advantage to three before Jim Gottfridsson inspired the Swedes to a 3-1 run to level matters at 8-8 midway through the half.
After Blagult missed two penalties to take the lead for the first time since 1-0, Portugal continued to nudge one or two goals ahead, but Sweden continued to peg them back, and Sebastian Karlsson's first of the game in the 30th minute sent the teams in at half-time inseparable, 16-16.
The turn-taking to score continued after the break, only this time it was Sweden edging ahead after Gottfridsson scored the opening goal, then the Scandinavians had their first two-goal lead when Hampus Wanne made it 21-19 in the 36th minute.
But another missed penalty and impressive Gustavo Capdeville saves meant Sweden failed to pull clear, and the always-dangerous Costa put the Portuguese ahead again at 23-22.
The lead continued to change hands, until Sweden put together a 3-0 run goals from Felix Claar, Lukas Sandell and Nikola Roganovic - who made amends with a penalty following previous misses from the line - to go 30-28 ahead with just over six minutes to play.
But the Iberian side would not lie down, as Francisco Costa and brother Martim led the fightback, making it 34-34 with a minute to play. Sweden then lost possession, and Martim Costa finished off a fastbreak to put Portugal ahead.
The drama wasn't over, as Sweden found Oscar Bergendahl at the line, and he levelled the scores once more with six seconds to play. After a time-out, Portugal turned to Martim, and fittingly it was his rocket from 9m that flew past Mikael Appelgren to win it at the buzzer, 36-35.
That goal was Martim Costa's ninth of the match, as he finished with one more than Sandell and two more than his brother, Francisco. Sweden can take some heart from the fact sixth place is enough for them to secure qualification for the 2027 World Championship.
What will be harder to take, is that after four consecutive wins to begin the tournament, Sweden won just one of their last four, while one defeat was essentially enough to deny them a shot at contesting the medal matches.
Tonight, the two places in Sunday's final will be decided, as Germany face Croatia (17:45 CET) and Denmark take on Iceland (20:30 CET) in the semi-finals, both also played in Herning.
