Mark Robins' Barnsley appeared to be on course for their first win in eight away league games as they defended a slender lead given to them by Marlon Harewood in the 22nd minute on Saturday.
But Paul McShane was sent off by referee Chris Sarginson for violent conduct in the 69th minute and Boro capitalised, with McDonald heading home his 11th goal of the season with six minutes left.
Barnsley took the lead in the 22nd minute with only their second effort on goal.
Tykes midfielder Nathan Doyle's shot was blocked by Kevin Thomson and from Kieran Trippier's subsequent corner the ball fell to Harewood six yards out and the on-loan Blackpool striker converted into the bottom corner.
Middlesbrough had only had one shot themselves prior to Barnsley's breakthrough, Rhys Williams letting fly from 30 yards, but his shot fizzed wide.
Barnsley midfielder Jacob Mellis, on loan from Chelsea, saw his goalbound shot from outside the penalty area hit Boro striker McDonald in the 33rd minute, but chances at either end were at a premium.
Home defender Joe Bennett picked himself up after being fouled by Danny Haynes to curl his 25-yard free-kick wide before Harewood was denied a second for the visitors just before the break when Boro goalkeeper Paul Smith tipped away his shot at full stretch.
Doyle and Barnsley defender Matt Hill both tried their luck with long-range shots early in the second half, while Barry Robson's fierce drive was blocked by Jason Shackell at the other end.
Andrew Taylor's shot was blocked by Tykes centre-half Shackell and Thomson fired wide as Boro chased an equaliser.
McDonald was on target with an angled shot, but Barnsley goalkeeper Luke Steele was equal to it, while the visitors fired a warning that they were capable of extending their lead in the 66th minute when Jacob Butterfield flashed a shot wide from the edge of the area.
Bennett's effort was held by Smith and Boro substitute Tarmo Kink lashed a shot over the crossbar before Harewood forced Smith into a fumbling save at the other end and Hill crashed a shot just off target.
But Boro cranked up the pressure, with Davies and Kink both heading inches over the crossbar before the Estonian striker, a 74th-minute replacement for Robson, provided the cross from the left for McDonald to head beyond Steele into the bottom corner.
Barnsley carved out two late chances, which both fell to midfielder Butterfield, but his first shot was blocked by Andrew Davies and his second effort from close range flew the wrong side of the post in the third minute of time added on.