Quick-fire goals from Jake Cooper and Lee Gregory after the break gave Millwall hope of a second league win of the season, after Billy Sharp had opened the scoring for the visitors.
But McGoldrick struck twice, the first coming from the penalty spot 10 minutes from time before tapping home from close range as the Blades picked up their sixth Championship win of the season despite Sharp missing a penalty.
Millwall, meanwhile, are now without a win in seven and sit in the relegation zone, with pressure mounting after their underwhelming start to the campaign.
A lively opening to the game saw the hosts have a goal disallowed but Sheffield United boasted a golden chance when a cross was adjudged to have been handled by Shaun Williams in the penalty area.
Sharp stepped up from 12 yards but Ben Amos’ superb save saw the ball tipped onto the bar, a moment that sparked the hosts into life.
Sharp redeemed himself just five minutes before the break, opening the scoring with a glancing header for his fifth league goal of the season.
Millwall fans voiced their disappointment at the break but the second half was a different matter, Cooper heading home from a corner just two minutes after the restart to level up the contest.
And just three minutes later the Lions were ahead for the first time when Ryan Leonard lobbed a ball behind the Blades backline for Gregory to run onto, taking a touch to then poke from the left side of the six-yard box into the far corner.
Spurred on by the vocal support, Millwall smothered United but two quick Blades chances, one thwarted by a superb Cooper tackle and another saved excellently by Amos, slightly slowed the momentum.
And the hard work was undone when Aiden O’Brien clattered into Mark Duffy from behind as United were awarded their second penalty of the game.
With Sharp removed from spot-kick duties, McGoldrick calmly stepped up and sent Amos the wrong way to level up at 2-2.
But United were not done there, with just two minutes left on the clock when McGoldrick stabbed home from close range, benefiting from sloppy defending to tap in from just three yards.
Millwall pushed in the latter stages but could not do enough to equalise for a second time in the game, still holding just one win from the Championship season.