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.
Megginson had scored an excellent goal to make the score 2-2
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.
- 19 Ewings
- 02 McGinn
- 03 Smith (McKerracher - 79' )
- 04 Graham
- 05 Barry
- 06 Turner
- 11 McDougall (Nish - 79' )
- 14 Flening (Megginson - 67' )
- 26 Murray
- 10 Smith
- 12 Prunty
- 01 Grindlay
- 21 Josh Horne
- 24 McKerracher
- 09 Megginson
- 17 Nish
- 01 Cierzniak
- 02 Dillon
- 04 Butcher
- 05 Souttar
- 03 Robertson
- 06 Paton Booked
- 10 Gauld (Millar - 83' )
- 11 Wilson (Ciftci - 63' )
- 07 Goodwillie (Erskene - 76' )
- 08 Rankin
- 09 Graham Booked
- 13 McCallum
- 12 Ciftci
- 15 Erskene
- 16 Millar
- 14 Gardyne