Hal Robson-Kanu came off the bench to score the winner as Wales made a victorious start to their Euro 2016 campaign with a 2-1 triumph over Slovakia in Bordeaux.
Substitute Robson-Kanu was the hero in Bordeaux as he latched on to a loose ball 10 minutes from time and finish past Matus Kozacik in the Slovakia goal.
Gareth Bale had earlier given Wales a 10th-minute lead with a trademark free-kick, the 20th goal for his country, but substitute Ondrej Duda equalised just after the hour mark as Slovakia began to turn the screw.
However, Robson-Kanu – a striker currently without a club – supplied a dramatic end to a game in which Wales had to defend for their lives at times and protect back-up goalkeeper Danny Ward.
The Liverpool man was called in at the 11th hour after first-choice stopper Wayne Hennessey suffered a back spasm on the eve of the game.
Wales supporters had arrived in their thousands at the Stade de Bordeaux to witness the end of a 58-year wait to see the nation play at a major tournament.
Chris Coleman’s side had failed to win any of their four friendlies since securing qualification, but Real Madrid forward Bale had not started any of those games and his presence in attack was a more than welcome sight.
In a group which also features England and Russia, it was Slovakia who almost scored from the game’s first attack when Marek Hamsik dispossessed Bale and left several Wales defenders trailing in his wake.
Hamsik had the goal at his mercy and drove his shot past Ward, but Ben Davies had managed to recover to produce a superb goal-line clearance.
It was a huge let-off for Wales but they were ahead not long after when a foul by Patrik Hrosovsky on Jonathan Williams nearly 30 yards out gave them a free-kick.
Bale lined up the kick and, although it was not in the corner of the goal, it still had too much power and dip to beat the outstretched hand of Kozacik.
The goal threw Slovakia out of their stride after such a promising start and Aaron Ramsey forced a straightforward save from Kozacik.
Wales were protecting Ward well and Slovakia wasted their own free-kick opportunity when Juraj Kucka fired over from 30 yards.
Martin Skrtel’s uncompromising challenge on Williams left Wales claiming a penalty, but Norwegian referee Svein Oddvar Moen was not interested in the appeals and waved play on.
Slovakia finished the opening half on top and they had the first chance of the second period when Robert Mak sprang the offside trap.
Mak burst on to Vladimir Weiss’ raking pass but was unable to control his shot.
Bale almost scored a second two minutes later when he met Allen’s cross and Kozacik had to scramble across his line to save by the post.
But Slovakia were taking a grip of proceedings and a double substitution paid off instantly.
Mak broke between the lines and he slipped a pass to Duda, whose firm left-footed shot gave Ward no chance to make it 1-1.
Ward was involved again when he had to beat away Kucka’s powerful effort with James Chester on hand to clear the danger.
Coleman responded with a double substitution of his own to stem the Slovakia flow, with Joe Ledley back five weeks after fracturing his leg and Robson-Kanu also sent on after injury.
The switch almost worked immediately as Robson-Kanu swung over a cross for the unmarked Ramsey eight yards out.
But the Arsenal midfielder got under the ball and sent his header over Kozacik’s crossbar.
Wales had altered the balance of play, though, and Ledley’s pass allowed Ramsey to run at the heart of the Slovakia defence.
Ramsey seemed to stumble but the ball broke to Robson-Kanu and, although his shot was scuffed, it found its way through the legs of Jan Durica and past Kozacik.
Slovakia were not finished, though, and substitute Adam Nemec headed against the post four minutes from time.
But Wales held on for a famous win which sees them take a huge stride towards the knock-out stages.