A dull game was heading for extra-time until Steven Anderson headed Saints in front in the 72nd minute.
A dull game was heading for extra-time until an own goal from Sean Dillon put Saints ahead in the 72nd minute.
The tie looked over four minutes later when Darren Dods deflected a free-kick from the excellent Liam Craig past his own goalkeeper, but Prince Buaben’s first goal in Scottish football set up a grandstand finish.
Former Rangers striker Jonatan Johansson made a surprise debut for Saints after signing for the club earlier in the day.
The 34-year-old Finland international, who was released by Hibernian last month, had been training with Derek McInnes’ side but his capture only became apparent when he was named in the team.
Johansson’s debut overshadowed another for goalkeeper Graeme Smith and a first appearance of the season for captain Kevin Rutkiewicz as Saints made six changes.
United, who made four of their own, were looking to make it a hat-trick of semi-final appearances, while Saints were hoping to emulate their run to the last four from 2006-07.
That included a 3-0 victory over United, who won 3-2 on their last trip to McDiarmid Park a month ago.
Tuesday night’s match was the first under the stadium’s new £100,000 floodlights and it should have been illuminated by a fifth-minute goal when a lovely left-wing Craig cross was headed wide by the unmarked Kenny Deuchar.
A lively-looking Johansson then fluffed his lines after racing onto a clipped Chris Millar ball, the new man smashing horribly wide from 15 yards.
Saints were getting in behind too easily and a Deuchar header forced a fine stop from the recalled Steve Banks, although the whistle had already gone for a foul.
United eventually got a foothold in the game and Danny Cadamarteri spoiled nifty footwork by blazing over from 18 yards in the 21st minute before Swanson followed suit in the 25th.
The recalled Craig sent in another pinpoint cross for Saints on the half-hour mark but Johansson and Murray Davidson got in each other’s way trying to head home.
Goodwillie was then narrowly wide with a rising 30-yard drive.
Eight minutes before the break, Chris Millar scuffed a first-time effort straight at Banks from Deuchar’s knockdown.
The big striker then had a half-chance of his own, but lifted it over the bar off balance from the edge of the box.
Half-time saw United bring on Dods for Andy Webster, who had recovered from illness to start.
Johannson missed a golden opportunity to net on his debut in the 51st minute when he nodded Deuchar’s flick-on off target from just six yards.
United’s fans screamed for a penalty when Cadamarteri tumbled over under pressure from Rutkiewicz but, tellingly, the forward made no appeal.
At the other end, Millar drove over left footed from 25 yards.
The returning Rutkiewicz was understandably replaced by Steven Anderson just past the hour.
Felipe Morais came on for Paul Sheerin in the 67th minutes as McInnes tried to end the stalemate.
And the opener finally arrived five minutes later courtesy of another fine Craig delivery, this time from a corner.
The ball actually deflected in off Dillon, although substitute Anderson celebrated as if he had scored.
United threw on Damian Casalinuovo for Fotheringham within four minutes of going behind but immediately conceded a second.
Craig was again the provider, his 40-yard free-kick flicking in off the unfortunate Dods.
Visiting boss Craig Levein made his final change as Craig Conway came on for Danny Swanson and was duly handed a lifeline eight minutes from time when Buaben looped a header over Smith after good work from Michael Kovacevic.
The keeper was booked for kicking the ball into the stands in frustration.
A frenetic finish saw United pour forward in search of an equaliser but Saints – who replaced Johannson with Kevin Moon late on – deservedly survived.