Danny Haynes returned to haunt his old club as Barnsley fought back to earn only their second win in 11 games.
Marvin Elliott put City ahead on six minutes before handling for a penalty netted by Andy Gray and Haynes followed up a weak Gray shot to make it 2-1.
Jacob Butterfield scored the goal of the game just before the break then turned provider for Paul McShane to head in the fourth in the second half.
Nicky Maynard's late penalty for a foul on Albert Adomah was no consolation.
Hugo Colace had already gone close for Barnsley before Elliott opened the scoring, converting Jordan Spence's pass.
But Barnsley were undaunted by the double setback of going a goal down and seeing Colace limp off injured, and were soon on level terms when Elliott handled and Gray made no mistake from the spot.
Kieran Trippier's free-kick tested City keeper David James before Haynes punished his former employers, and just before half-time Butterfield's strike from the left corner of the box put the Tykes in control.
James was busy after the restart, keeping out Haynes, but the former England keeper was beaten when McShane, on loan from Hull, headed home Butterfield's cross from close range.
Late on, Maynard scored from the spot after Stephen Foster fouled Adomah, but it was too late to make any difference.