Ismail Yakubu and Liam Hatch scored as Barnet came from 1-0 down to dump Gillingham out of the FA Cup.
The Gills broke the deadlock when David Graham headed home Nicky Southall's cross from five yards and he scuffed a great chance to make it 2-0.
Minutes later Barnet drew level when Yakubu headed home after Josh Wright's free-kick was not cleared properly.
Kenny Gillet's cross was then powered home by Hatch before the hosts' Ashley Carew received a second yellow card.
Barnet: Harrison, Devera, Yakubu, Burton, Gillet, Carew, Bishop, Wright (Leary 69), Puncheon, Hatch, Birchall (Nicolau 90).
Subs Not Used: Beckwith, Grazioli, O'Cearuill.
Sent Off: Carew (86).
Booked: Bishop, Carew.
Goals: Yakubu 61, Hatch 63.
Gillingham: Royce, Southall, Cox, Sodje (Freeman 80), King, Cogan, Lomas (Crofts 72), Bentley, Brown, Facey (Mulligan 72), Graham.
Subs Not Used: Stillie, Clohessy.
Booked: Bentley, Cogan.
Goals: Graham 27.
Ref: Pat Miller (Bedfordshire).