A fourth minute own goal by Byron Anthony proved enough to send Bangor City through to the semi-finals of the FAW Premier Cup for the first time.
Stuart Fleetwood had Cardiff's best chance to equalise at Farrar Road
The Cardiff captain, one of only four with first-team experience, headed in a in-swinging corner from Kevin Scott.
Tony Gray and Paul Roberts then went close for the home side before Stuart Fleetwood had Cardiff's best chance.
Bangor's Eifion Jones had a goal ruled out for pushing, but the Welsh Premier side held on for a famous victory.
Bangor City: P Priestley, C Blackmore, K Scott, E Jones, P Hoy, P Baker, M Connelly, O Jones, P Roberts, T Gray, L Davies (F Mottram 88).
Subs: C Short, R Owen, B Ogilvey, C Garside.
Cardiff City: A Lee-Barrett, B Anthony, K Huggins, N Fish (M Parkins 86), D Parslow, J Rewbury, A Taylor, T Koskela, S Fleetwood, D Thomas (J Easter 60), J Kift (C McDonald 68).
Subs: S Allison, R Morgan.