After beating Poland on matchday one, Stefan Tarkovic's side knew another victory would secure their place in the next round before their final group game with Spain.
But it was Sweden who produced more of a consistent attacking threat – certainly compared with their goalless draw with Spain, when they had just 15 percent of the possession – as they sought to avoid going four consecutive European Championship games without scoring.
Alexander Isak was their most threatening player and it was the Real Sociedad striker's clever through ball that saw Robin Quaison fouled by goalkeeper Martin Dubravka, allowing Emil Forsberg to win the contest from the penalty spot.
There was little ambition shown by either side in a first half in which the only shot on target occurred after three minutes, Sebastian Larsson's deflected effort from the edge of the box proving a comfortable save for Dubravka.
Slovakia enjoyed more of the possession but were not prepared to commit too many to the attack, while Sweden seemed content to wait for their chances.
Their first real openings came just before the hour mark. Ludwig Augustinsson's header from Larsson's cross was superbly saved by Dubravka, with Marcus Danielson nodding over from the resulting corner.
Isak at last came to life in the final 30 minutes, heading narrowly over before testing Dubravka with a good right-footed shot from the edge of the box after a strong run.
It was Isak's first-time pass that saw Dubravka commit and bring down Quaison, allowing Forsberg to slot home from 12 yards and end a 365-minute wait for a Sweden goal at the Euros, their last coming against the Republic of Ireland five years ago.
What does it mean? Sweden take charge of Group E
With four points from two games, Sweden will now go into their final group game with Poland in a strong position to reach the next round.
Slovakia stay on three points and will be overtaken by Spain should they defeat Poland, who must avoid defeat if they are to finish in the top two.
Isak at last provides the spark
After a deeply uninspiring first half, it was Sweden who began to take more risks after the interval as Isak became increasingly involved.
The striker completed six dribbles, the most by any player in a single game at this tournament, and provided the moment of inspiration that led to the penalty.
Slovakia pay for caution
Slovakia seemed to have the game more or less under control in the first half, but they did not match Sweden's improved intensity after the interval.
Their possession dropped from 61.4 per cent to 54.5 per cent from the first half to the second, while they failed to manage a shot on target throughout.
Sweden face Poland in St Petersburg and Slovakia meet Spain in Seville, with each game on June 23.