Bangor City ran Wrexham close as the FAW Premier Cup holders needed a late goal to beat the Welsh Premier League side and book a place in the final at the Vetch Field against Swansea City next month.
Paul Roberts gave
Wrexham later had a goal ruled out for offside while Bangor hit the post before the end of the half.
Former Preiership player Chris Armstrong got the equaliser from a penalty after being brought down by Phil Priestly, and then Mark Jones grabbed an 85th minute winner with the match drawing to an end.