Having drawn against both Norway and Sweden in their last two matches on their trip to Scandinavia, the Spaniards will have plenty of work to do if they want to be considered among the favourites at next year's tournament.
With Sergio Ramos suspended following his yellow card in their last game against Norway, Spain started superbly, pinging the ball from side to side and probing for openings behind the Swedish defence.
Thiago Alcantara could have put the visitors ahead early on, but after rounding the goalkeeper he miscontrolled the ball and it rolled out for a goal kick.
Midfielder Rodri had a stinging shot saved shortly afterwards and it looked to be only a matter of time before the Spaniards made the breakthrough, but with goalkeeper Robin Olsen in superb form, the Swedes adjusted and began to grow into the game.
With light rain falling throughout the game, players struggled to keep their footing on the Friends Arena surface.
Striker Berg put Sweden in front early in the second half after his initial header was saved, as was Emil Forsberg's shot, but Berg nodded home from close range at the second attempt to give his side the lead.
De Gea left the fray injured on the hour mark and despite dominating possession throughout, Spain found it almost impossible to create the kind of chances they had enjoyed in the opening exchanges.
The crowd of over 49,000 in the stands were in fine voice as they ignored the damp weather with the final whistle approaching, but Rodrigo silenced them by snapping up a ball form a corner and rifling it home to send Spain through.
"I am very happy, the players were very good and we met a very strong rival. It was tough for us, but we corrected what needed to be corrected," Spain coach Robert Moreno told reporters.
"It's great that have achieved this, there's a lot less pressure and now in three weeks we play Malta. We must focus on playing well in the remaining matches," he added.
Sweden coach Janne Andersson said he was happy with his players, despite them conceding a late goal.
"That's football, it happens sometimes. I can't sit here and be annoyed with players who have given everything," he told a reporters.
Elsewhere in the group, the Faroe Islands secured their first win of the campaign with a 1-0 home win over Malta, while Romania drew 1-1 at home to Norway.
Spain top the group on 20 points with the Swedes second on 15 and Romania a point further back, with those two sides set to meet in Romania on Nov. 15. Norway are fourth on 11 points.