Ieuan Owen netted twice as Barry Town United stunned The New Saints in Bridgend to lift the Nathaniel MG Cup for the first time in 26 years.
Andy Legg's side went ahead two minutes before half time as the Saints failed to clear Michael George's cross, allowing Owen to bundle home his 15th goal of the season across all competitions.
Craig Harrison's men had goalkeeper Jack Edwards to thank for producing a vital one-handed save to keep out another Owen strike on 75 minutes.
But Owen completed his brace from 25 yards out in the first minute of second half added time as the Linnets - the second-most successful side in the competition's history, behind TNS - won the tournament for a fifth time.
Both sides had a player sent off in the final seconds, with TNS' Rory Holden and Barry's Callum Sainty being dismissed.
Victory was Barry's third in succession across all competitions and brought an end to the Saints' six-game winning run.