The former Reading winger rose from the bench to win the game for his country, scuffing a finish home after Ondrej Duda had cancelled out Gareth Bale's sublime openerWales' first major international tournament match in 58 years ended in victory as Hal Robson-Kanu struck late to seal a 2-1 Euro 2016 win against Slovakia.
Gareth Bale stepped up to beat Matus Kozacik with a brilliant whipped free-kick from 30 yards to put his side into an early lead in Bordeaux.
Bale had scored or assisted nine of the 11 Wales goals in qualifying and the Real Madrid forward seemed to have made the difference for his team once more.
But substitute Ondrej Duda had other ideas, shooting low past Danny Ward after superb work by Robert Mak early in the second half.
Another substitute then struck the decisive blow with 10 minutes to go as Robson-Kanu bundled in an untidy finish after Aaron Ramsey created the opening.
Slovakia's unbeaten run ends at eight games as a result of their defeat, with Russia up next for Jan Kozak's side, while Wales will be buoyed ahead of their clash against England in Lens on Thursday.
All the pre-match build-up had focused on Bale against Hamsik, and it was the Slovakia star who was first to threaten with a brilliant solo run inside three minutes.
Sign up here with your email
ConversionConversion EmoticonEmoticon