The visitors started the game well and duly took the lead when Nikola Zigic prodded the ball home from close range in the 10th minute.
Huddersfield pressed to get a leveller immediately but Jon Stead could only head Paul Dixon's cross over the bar after the defender found him in the penalty area.
However, the Terriers did get their equaliser in the 31st minute when Adam Hammill lifted a cross into the penalty area and Anthony Gerrard rose highest to head the ball past Darren Randolph into the net.
After the break, both teams threatened to go ahead. First, City had an opportunity when Lee Novak fired an effort at goal from distance that was well saved by Alex Smithies, and at the other end Adam Hammill shot just past the post from inside the box.
Birmingham secured the win in the 81st minute when Bartley scored again as he nodded Lingard's free kick past Smithies, but he was then sent off for removing his shirt in celebration for his second bookable offence.