Wales dominated possession but, in the absence of injured star forward Gareth Bale, lacked conviction in the final third and saw their 10-match unbeaten run in competitive home fixtures brought to an end by McClean.
Although top spot in Group in D was not out of reach for either side before kick-off, Serbia's 1-0 victory over Georgia gained them automatic qualification to Russia 2018 and forced Martin O'Neill's side into the play-offs.
Chris Coleman's men appeared to be in control from kick-off but struggled for creativity after a blow to the head resulted in Joe Allen being substituted before half-time.
It was a lapse in concentration that ultimately cost Wales. Wayne Hennessey rolled the ball out to Ashley Williams and the industrious Jeff Hendrick stole possession to set up McClean to lash home a winner for the third time in the campaign.
2 - In the other two 2018 World Cup qualifiers that James McClean has scored in, he's netted the winning goal. Omen? pic.twitter.com/Gtm4ND8ehu— OptaJoe (@OptaJoe) October 9, 2017
After a sensational run to the semi-finals of Euro 2016, elimination will come as a bitter blow for Wales, whose wait to reach a World Cup finals for the first time since 1958 continues.
The hosts looked to pile on early pressure and Hal Robson-Kanu – replacing Sam Vokes in Coleman's only change from the 1-0 victory over Georgia – headed a delivery from Joe Ledley narrowly off target from the near post in the third minute.
Wales controlled the ball and Ireland only got a chance to get the ball forward when Allen was booked for a swipe at Meyler's legs. Robbie Brady's free-kick was kept alive by McClean, whose dangerous low cross from the left was turned behind by Ashley Williams.
Hendrick was unable to add a finishing touch following a scramble in the Wales box, while Tom Lawrence's attempt to repeat his goalscoring heroics in Tbilisi saw his effort deflected into the arms of Ireland goalkeeper Darren Randolph.
Allen was replaced by Jonny Williams in the 37th minute after taking a blow to the head from Meyler as he leapt to challenge for a high ball and Wales struggled to create anything further before the break, Ireland looking comfortable as they sat back.
The hosts again came out positively and eight minutes after the restart Robson-Kanu saw a powerful header from Jonny Williams' right-wing cross brilliantly palmed over by Randolph.
Ireland punished Wales' shortcomings in the final third when Hennessey's distribution put Ashley Williams under pressure and he was dispossessed by Hendrick. He raced away from the Everton defender and pulled a quality cross back to McClean, who rifled an unerring finish into the bottom-right corner.
Coleman introduced Ben Woodburn – who netted the winner on debut against Austria – and Vokes in an attempt to galvanise his side and they nearly combined for an equaliser with nine minutes remaining, but the Burnley striker was unable to connect with a sweet inswinging cross from his fellow substitute.
O'Neill's men remained resolute and showed the same defensive solidity they did before the break to see out a famous victory and break Welsh hearts, but their own journey is not over yet and they will be without captain Meyler for the first leg of the play-offs after his stoppage-time booking.
Key Opta Facts:
- Wales have won just one of their last 11 matches against the Republic of Ireland (W1 D4 L6) and none of the last eight.
- This victory means that Ireland ended the 2018 World Cup qualifiers unbeaten away from home (W3 D2 L0).
- This was Wales' first competitive home defeat since September 2013 (versus Serbia), ending an unbeaten run of 10 matches (W6 D4 L0).
- James McClean scored his fourth goal of this qualification campaign, meaning he ended as as Ireland's top goalscorer.
- All four of McClean's goals in these qualifiers came in the second half of away matches.
McClean scored the winning goal in three different matches for Ireland in the 2018 World Cup qualifiers – without his goals, they would have been six points worse off.
This game saw 58 aerial duels contested – the most in a single game during in this UEFA Qualification campaign for World Cup 2018.