Saints netted three times in 11 minutes through Thompson and Nigel Hasselbaink to quickly turn the second-round clash on its head.
Morton led at half-time following well-worked goals from Michael Tidser and Peter MacDonald and they pushed their Clydesdale Bank Premier League opponents all the way after Andy Jackson pulled a goal back in the 79th minute.
The goals started in the ninth minute after the hosts had been penalised for handball by referee Calum Murray after Grant Evans and Tidser charged down Jim Goodwin's shot. Gary Teale powered the free-kick into the top corner from 20 yards.
Saints then had almost exclusive possession for a long spell with Morton sitting deep with everyone but MacDonald behind the ball.
But openings in the final third were proving difficult to find and the Greenock side levelled in the 17th minute after Saints lost possession on the halfway line.
Tidser ran unchallenged to the edge of the box and was clean through after a one-two with MacDonald. The 21-year-old slotted home from 10 yards as the Saints defence looked hopefully for an offside flag.
Thompson headed wide under pressure following Teale's cross but Morton went straight up the park to score in the 27th minute.
Tidser fed MacDonald with a pass from the left wing and the former St Johnstone striker turned inside Lee Mair before curling the ball into the top corner from 16 yards.
Morton began to press further up the park and looked more confident on the ball and Paul Di Giacomo swerved a 25-yard shot wide before half-time.
Both sides survived penalty scares early in the second half. The home side appealed for handball when a grounded Paul McGowan stopped Di Giacomo's low cross and Thompson was then knocked over by the falling Evans, who had his back to his opponent after contesting a high ball.
Saints levelled in the 55th minute when Thompson sidefooted home from 10 yards after reacting quickly to meet Hasselbaink's low cross after the Dutchman had worked himself a yard of space on the right.
Thompson soon returned the favour and Evans was a fraction late with a challenge on his former Hamilton team-mate to concede a penalty.
With Thompson having missed a spot-kick at Dunfermline on the opening day of the season, Hasselbaink took responsibility and sent Colin Stewart the wrong way.
Saints moved further ahead in the 66th minute when Thompson attacked Jeroen Tesselaar's arching cross following Teale's short corner and headed powerfully into the corner of the net from six yards.
Jon McShane replaced the injured Hasselbaink and Illias Haddad came on in midfield for Teale as Saints sat back and soaked up the pressure.
The visitors should have extended their lead but McShane shot wide after beating the offside trap and Thompson lifted the ball on to the top of the crossbar following Stewart's dreadful goal-kick.
Morton substitute Jackson brought the game back to life when he shot into the bottom corner from 20 yards and there was a late scare for Saints when Jackson's low cross found MacDonald 12 yards out.
The striker beat Goodwin to the ball but Craig Samson got down well to save his shot and secure St Mirren's progress.