McGoldrick’s 84th-minute free-kick and Christophe Berra’s close-range finish three minutes earlier cancelled out the Tykes’ two-goal lead, given to them by Chris O’Grady and Tomasz Cywka.
The result extended the Tractor Boys’ unbeaten run to four games and moved them to within three points of the top six, while leaving relegation-threatened Barnsley four points adrift of safety.
Tykes’ top-scorer O’Grady should have put the home side ahead in the sixth minute but, after midfielder Stephen Dawson dispossessed Stephen Hunt on the edge of the box, the striker fired tamely wide with only Town goalkeeper Dean Gerken to beat.
O’Grady did not have to wait long for an opportunity to make amends and duly opened the scoring with 12 minutes played.
The former Sheffield Wednesday man collected a ball into the box from full-back Jack Hunt and, with his back to goal, twisted and turned before finding the bottom left-hand corner with his left foot for his 11th goal of the season.
Town left-back Aaron Cresswell went to close to restoring parity five minutes later but his 25-yard free-kick, following Dawson’s foul on Hunt, cannoned back off the right-hand post with Barnsley goalkeeper Luke Steele beaten.
Tractor Boys striker Frank Nouble saw a 20-yard strike comfortably saved by Steele as half-time approached, while defender Tommy Smith headed wide at the near post from a Hunt corner two minutes before the break.
Town midfielder Cole Skuse went close with a drilled effort from the edge of the box, which flew inches wide eight minutes after the restart, prior to substitute Paul Anderson shooting high and wide from close range after Steele could only parry Hunt’s low ball into the box.
Winger Anderson, a 52nd-minute replacement for Nouble, volleyed wide from Creswell’s cross just after the hour mark before Steele produced a brilliant double save to deny Daryl Murphy’s stinging shot and Anderson’s follow-up effort.
Ipswich were made to pay for their profligacy with 16 minutes remaining when Barnsley doubled their advantage.
Substitute Tomasz Cywka drilled a free-kick from the left-corner of the 18-yard box, following a foul on O’Grady, and the strike took a nick off McGoldrick before flying into the far corner past the stranded Gerken.
Centre-back Berra tapped into the roof of the net from from close range after Jim O’Brien blocked Smith’s header on the line to halve the deficit with nine minutes remaining and Hunt should have levelled the contest moments later when he flicked agonisingly wide from Murphy’s centre.
Striker McGoldrick then made up for his part in Barnsley’s second with a powerful free-kick from the edge of the box, which took a slight deflection on its way into the roof of Steele’s goal six minutes from time.