Hamsik's pass released Vladimir Weiss to score in the 32nd minute at the Stade Pierre Mauroy and the Napoli star doubled the lead in style right on the stroke of half-time.
Russia pushed in the second half, but were left with too much to do, even if Denis Glushakov got one back in the 80th minute to set up a grandstand finale.
Euro 2016: Kane should fear being replaced by Vardy, says Shearer
The result allowed Jan Kozak's team to bounce back from the 2-1 defeat to Wales with which they started their Euro 2016 campaign and put pressure on their Group B rivals before England take on the Welsh in Lens on Thursday.
Russia prop up the group with one point from two matches and will surely now need to beat Wales in their final group game to keep their hopes of reaching the last 16 alive.
The build-up to this match in far northern France had been overshadowed by hooliganism fears with Russia having been told they would be thrown out of the competition if there was any repeat of the crowd trouble at the end of their draw with England in Marseille.
Euro 2016: Pelle cracker caps Italy win over Belgium
However, there was a much calmer atmosphere inside the stands, while the match was played with the stadium roof closed.
Kozak made three changes to the Slovakia team beaten by Wales, including handing a start to Ondrej Duda, the young forward who had come off the bench to net in the opening match.
After a slow start Russia grew into the game and their powerful centre-forward Artem Dzyuba, of Zenit St Petersburg, nearly caught out Slovakian 'keeper Matus Kovacik with a header after good play down the right by Igor Smolnikov.
Dzyuba then displayed his strength to set up Fedor Smolov for a low shot that fizzed inches wide of the left post as the half-hour approached, but soon after that Slovakia were in front.
Hamsik undid the Russia defence with a superb left-foot pass in behind right-back Igor Smolnikov. Weiss still had work to do though, as he cut back onto his right foot and finished with aplomb past Igor Akinfeev into the far corner.
Leonid Slutsky's side were stunned, but there was worse to come for them, and better from Hamsik, as the interval approached.
The Russian defence was still organising itself when Weiss played a corner short to Hamsik. Oleg Shatov came across in an attempt to block Hamsik but the 28-year-old turned back onto his right foot and curled a tremendous effort in off the far post.
It was arguably the goal of Euro 2016 so far and it had the Slovakians at that end of the ground in raptures.
Slutsky changed his two central midfielders at half-time, replacing Roman Neustaedter and Aleksandr Golovin with Glushakov and Pavel Mamaev.
It was Glushakov of Spartak Moscow who reduced the arrears in the 80th minute, heading home after Shatov had played a one-two with Roman Shirokov and crossed from the left byline. But Slovakia held on.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ