Boro's place in the top two had come under threat after three games without a win, but Targett emerged as the unlikely hero to put Kim Hellberg's side back on track as they seek a return to the Premier League for the first time since 2017.
Former Aston Villa left-back Targett ran onto a long ball forward from Aidan Morris and steered past Birmingham goalkeeper James Beadle to give Boro the lead on 13 minutes at St Andrew's.
Targett struck again in the first half after a mistake by Birmingham centre-back Christoph Klarer, but Birmingham got back into the game when twice-capped Germany international Marvin Ducksch finished off a clever team move just after the break.
David Strelec headed in to restore Boro's two-goal lead as the visitors climbed to within five points of league leaders Coventry, while also putting some distance between themselves and third-placed Millwall.
"It was massive, obviously we're just focusing on ourselves but with everyone else winning it was important that we responded," Targett told Sky Sports after the first brace of his career.
"It's a rollercoaster, there's going to be plenty more ups and downs, so we take one game at a time but it was an important win."
Millwall are four points behind Boro, with Ipswich and Hull another two points adrift. Wrexham occupy the final play-off place as the Hollywood-backed Welsh side chase a fourth consecutive promotion.
It was only Birmingham's second home defeat in their past 42 league games, coming off the back off a 3-0 loss at Millwall last week that snapped an eight-match unbeaten run. The Blues are 12th and sit eight points off the play-offs.
