Bradford fought back from 2-0 down to record their second successive home win with a sparkling second-half rally.
Early goals from Mark Bentley and Mick Flynn - both created by Matt Jarvis - gave Gillingham an early advantage.
But defender Mark Bower pulled a goal back before half-time after the visitors failed to clear a corner.
Dean Windass equalised after Kelvin Jack saved his penalty and the striker put Bradford ahead on 82 minutes, before Jermaine Johnson added a fourth.