Nadir Ciftci came off the bench to fire Dundee United into the Scottish League Cup third round as he scored twice and set up another to see off Dumbarton.
Kevin Smith's first-half strike put the Sons ahead, but Ciftci fired home the equaliser after 69 minutes.
He set up Ryan Gauld to put the Premiership side in front.
Mitch Megginson scored a wonderful late equaliser, but Ciftci soon hit an 89th-minute winner to deny the Championship outfit the chance of extra time.
United had created numerous chances in the opening 15 minutes and Goodwillie sent a free header wide from a Mark Wilson cross.
Brian Graham had a volley well saved by Jamie Ewings following Andrew Robertson's cross.
Robertson sliced wide after being set up by Gauld, while Bryan Prunty glanced a header wide at the other end.
United could not maintain their early pressure, but they looked to be in little danger themselves until the 33rd minute.
Dumbarton right-back Paul McGinn sent a ball into Smith from the halfway line and the forward turned John Souttar and shot past the onrushing Radoslaw Cierzniak with the United defender only helping the ball into the net as he tried to atone for his error.
United almost levelled instantly when Gauld hit a swerving 30-yard effort that bounced off the bar.
Graham missed a late first-half chance and United hit the frame of the goal again 10 minutes after the break through a Paul Paton drive.
Barry nearly scored at the other end, but Robertson blocked his volley in the goalmouth just before United manager Jackie McNamara introduced Ciftci for Wilson in the 63rd minute.
Six minutes later, Ciftci chested the ball inside Scott Smith after the Sons left-back misjudged Paton's diagonal ball and the winger volleyed home inside the near post.
Ciftci set up the second when he used his pace and strength to make the bye-line before cutting it across goal.
Gauld's first effort was blocked, but the teenager had time to take a touch before rifling the rebound into the net from close range.
United sat back and Megginson made them pay with four minutes left when he curled the ball into the far top corner.
Parity lasted only two minutes as both United substitutes combined to win the tie, Chris Erskine cutting inside from the right wing and playing a reverse pass to Ciftci to fire home from 10 yards.
Sorry, we were unable to load match stats, please try again.