Referee Mike Tumilty harshly sent off Steven Anderson after 15 minutes and then banished Saints manager Derek McInnes from the touchline after he remonstrated with assistant referee Keith Sorbie in the aftermath of Johnny Russell's controversial opener - claiming the United player had scored from an offside position.
Sorbie had an eventful afternoon. It was his intervention that convinced Tumilty to give Anderson a second yellow card for an apparent foul on Swanson. It seemed clear to everyone inside Tannadice that the United winger had gone down easily and television replays backed this up.
St Johnstone performed admirably with 10 men but David Robertson's late second sealed the win for United and allowed them to move five points ahead of Kilmarnock in the race to finish fourth.
The visitors' winless run in the league has extended to nine games and they face leaders Celtic on Tuesday night before Saturday's Scottish Cup semi-final against Motherwell.
McInnes shuffled his squad in a bid to keep his players fresh ahead of next week's Hampden date. Graeme Smith, Steven Anderson, Peter MacDonald and Collin Samuel all started at Tannadice, with Peter Enckelman, Dave Mackay, Liam Craig and Jordan Robertson dropping out.
United manager Peter Houston made three changes following the 2-1 loss at Motherwell on Wednesday night. Scott Robertson, David Robertson and Keith Watson dropped out, with Prince Buaben, Danny Swanson and Garry Kenneth returned. It was Kenneth's first start since February 19 against Hearts.
St Johnstone defender Anderson was booked in 55 seconds for a crude lunge on Swanson. Prince Buaben blazed the free-kick high over the bar. Craig Conway then fizzed a cross into the box but Saints goalkeeper Smith punched clear under pressure from David Goodwillie.
Anderson was walking a tightrope and sent Swanson sprawling again with another bad tackle in eight minutes. It could easily have been a second yellow card, but referee Tumilty let the defender off.
However, Anderson would not last much longer, with the defender being sent off in 15 minutes. Again, he was penalised for a challenge on Swanson but there was no contact at all as the United winger threw himself to the ground.
Tumilty did not immediately give the foul but assistant referee Keith Sorbie flagged and action was taken against Anderson. McInnes ran 40 yards down the track to protest at the decision.
Peter MacDonald was replaced by Graham Gartland as St Johnstone were initially rocked by the loss Anderson but rallied and Danny Grainger's curling 25-yard free-kick was tipped over by Dusan Pernis.
The home goalkeeper was kept busy and he pulled off another superb save from Murray Davidson in 26 minutes after the midfielder found a yard of space and arrowed a low shot towards the bottom corner.
United were subdued but Swanson nipped in ahead of Michael Duberry to connect with Craig Conway's cross and force an instinctive save from St Johnstone goalkeeper Smith.
On the stroke of half-time Russell fired United ahead. Swanson's shot was deflected into his path by David Goodwillie and Russell rounded Smith to score.
The visiting players complained Russell was offside and manager McInnes was sent to the stand by referee Tumilty after taking the protests too far.
Danny Invincibile was trying to support Samuel as much as possible and he caused a scare in the United box when his bouncing shot was spilled by Pernis. Scott Severin cleared the danger.
Goodwillie showed wonderful skill in 65 minutes to spin away from Duberry and create space for Russell, but his low shot skidded wide.
Jordan Robertson replaced Invincible in 77 minutes and his cross almost picked out Chris Millar at the back post as they chased an equaliser.
Goodwillie was United's main threat in the second half and he teed up substitute David Robertson for the clincher in 85 minutes, racing to the byline and picking out the midfielder for a simple eight-yard finish.
Saints' Robertson could have halved the deficit in the closing stages but Dillon's superb saving tackle denied a certain goal. Pernis then saved superbly from Davidson in injury-time.