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 per cent 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 throughball 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.