The Irish, beaten 57-15 by England, won in Cardiff for the first time since August 2015 after scoring three tries in the Rugby World Cup warm-up match, two for Jacob Stockdale and a penalty try bringing Wales' 11-game home winning streak stretching back to November 2017 to an end.
The two teams meet again next Saturday in Dublin and the defeat will rankle more with Gatland as he remains bitter about the manner in which he was dismissed as head coach by the Irish in 2001.
"It was massive for us," man of the match Jack Carty told Channel 4.
"We were all hurting during the week but we came together. It wasn't perfect at times but our defence was good against a quality Welsh outfit."
The consolation for Gatland -- who according to team members was a bit 'choked up' when he spoke to them at the team hotel -- was the performance of Rhys Patchell.
He looks sure to be the back-up fly-half to Dan Biggar when the squad is announced on Sunday after having come on at half-time he almost propelled the hosts to an unlikely win having trailed 22-3.
Irish flyhalf Carty opened the scoring in the ninth minute with a sweetly-struck penalty from 40 metres out.
Jarrod Evans levelled with a penalty on the quarter-hour mark.
However, the visitors regained the advantage with a superb team try in the 18th minute.
Prop Dave Kilcoyne brushed aside Josh Navidi, Carty offloaded to Conway who made huge inroads breezing past several Welsh defenders.
The 28-year-old wing could have gone for glory on his own but unselfishly passed to Stockdale who ran in to touch down -- the wing let out some of the pent up emotion from heavy criticism of his defence last weekend by beating his chest and pulled on the Irish badge.
Stockdale grabbed his second when he showed his poaching qualities shortly before the half hour mark.
Aaron Shingler over elaborated with a backhand pass which went to ground and the Ulster star pounced to kick ahead handed off Hallam Amos and touched down -- Carty this time was unable to convert.
The Irish put a lot of pressure on the Welsh scrum in the second-half and replacement prop Leon Brown got sin-binned in the 52nd minute.
The Irish camped in the Welsh five metres and referee Romain Poite eventually lost patience and awarded the Irish a penalty try to give the visitors a 22-3 lead.
The Welsh got back into the game or at least offered themselves some hope as Owen Lane -- who had a rough time in the first-half with Stockdale -- side-stepped two tacklers and touched down.
Patchell converted brilliantly from the touchline for 22-10 with 15 minutes remaining.
Ireland had Luke McGrath -- nick-named 'The Ferret' -- to thank for denying Elliot Dee his first Test try as he dislodged the ball from the replacement hooker's hand as he stretched to touch down.
Patchell had transformed the Welsh side in the second-half and he deservedly got a try himself with less than five minutes remaining sidestepping Ringrose to touch down and converting for good measure.
However, the Irish forced one more turnover and secured a much-needed victory.