Emil Forsberg's 77th-minute penalty settled an encounter which was low on chances and entertainment but lifted Jan Andersson's side on to four points, leaving Slovakia likely needing to get a result against Spain in their final Euro 2020 Group E fixture to progress.
After their draw in the opener against Spain, in which they had just 15 per cent possession, Sweden were again content to concede the majority of the ball to their unambitious opponents.
It led to a dour game which only briefly sprang to life around the hour mark with a flurry of chances which culminated in Newcastle goalkeeper Martin Dubravka bringing down substitute Robin Quaison to allow Forsberg to end the team's run of 365 minutes without a goal at the European Championship.
Dubravka produced a similarly impressive save from Ludwig Augustinsson, who rose highest to meet Sebastian Larsson's cross, but this one would have counted. From the resulting corner Marcus Danielson's twisting header from six yards flew over.
LaLiga's young player of the year Alexander Isak then came to the fore with the Real Sociedad player, after having a shot from distance deflected wide, heading on to the roof of the net.
The 21-year-old's weaving run from 40 yards out lit up the St Petersburg Stadium and ended with him forcing a near-post save out of Dubravka but the Slovakia goalkeeper was caught on his heels moments later.
Isak's spinning through-ball on the turn fell to Quaison and although Dubravka pulled out of the challenge his momentum brought down the substitute. And Forsberg finally broke the deadlock to put his nation within touching distance of the last 16.