Wales’ penultimate game before the World Cup ended in a 2-1 Nations League defeat by Belgium in Brussels.
Kevin De Bruyne and Michy Batshuayi rewarded Belgium’s first-half dominance with well-worked goals and Wales looked as if they may suffer a hiding.
But Kieffer Moore halved the deficit five minutes after the interval, and Robert Page’s side produced a much-improved second-half performance to offer encouragement two months before the World Cup in Qatar.
Wales will head into their final Nations League game at home to Poland on Sunday with their survival hopes intact.
Poland’s 2-0 home defeat to Holland means that bottom-placed Wales can leapfrog them with a Cardiff victory and remain in the top tier of European football.
Wales had been disrupted by injuries with Aaron Ramsey, Ben Davies, Harry Wilson and Joe Allen all missing out.
Skipper Gareth Bale was among the substitutes following his late arrival into camp from the United States on Tuesday.
Bale, who has been slowly building up his fitness stateside ahead of the World Cup, had played for Los Angeles FC in the early hours of Monday morning UK time.
This was the ninth meeting between the two countries over the last decade, with Wales having held their own with two wins, two defeats and four draws in that time.
De Bruyne had said before the game he was bored of playing Wales so much, but the Manchester City midfielder did not show it as he produced a masterful performance.
Brennan Johnson had scored a late equaliser when the sides met in Cardiff three months ago, and the Nottingham Forest winger formed a three-pronged attack alongside Moore and Daniel James.
Belgium had seven starters in the side that lost to Wales in the Euro 2016 quarter-finals, including De Bruyne, Thibaut Courtois and skipper Eden Hazard.
Wales started in confident fashion but fell behind after 10 minutes when Batshuayi’s cross found De Bruyne and he casually guided it past Wayne Hennessey, who got a hand to the shot.
Youri Tielemans and Hazard were within inches of doubling the lead and De Bruyne, revelling in the generous space afforded to him, thudded a shot against a post.
De Bruyne soon set up Belgium’s second after 37 minutes, rolling a defender superbly and crossing for Batshuayi to convert the simplest of tap-ins.
There was brief respite for Wales as Joe Rodon went close and Courtois parried Ethan Ampadu’s follow-up header.
But Wales were only spared falling further behind when Hennessey’s outstretched leg pushed another De Bruyne effort around a post.
Wales got back in the contest with a goal out of nothing.
Johnson twisted and turned his way towards the Belgium box with a mazy 40-yard run, and Moore rose at the far post to head home his cross in style.
Wales sent on Bale just after the hour mark and he was soon in the action, meeting a James cross that was deflected over.
Belgium were awarded a penalty for a foul on De Bruyne. But replays showed that Joe Morrell had made contact with the ball and the decision was overturned on VAR review.