Henri Anier and John Sutton had struck inside the first half hour to put Europa League-chasing Motherwell 2-0 up before Thompson reduced the arrears three minutes before the interval.
McLean buried an 86th-minute penalty to level before Thompson won the game a minute later for the Paisley men.
Midfielder Lionel Ainsworth had combined with Anier to spring Saints' offside trap for Motherwell's 16th-minute opener, with Estonia forward Anier tapping in.
Sutton made it 2-0 11 minutes later by heading home from close range after Ainsworth knocked back Steven Hammell's pass.
Thompson reduced the arrears three minutes before the interval for Saints before the late drama claimed only an eighth league victory for the home side.
Former Scotland forward Thompson outjumped Well's Stephen McManus early, but headed wide of the visitors' goal, before Sutton looped one of his own just wide of a Saints post from 12 yards.
Anier slotted the Fir Park men ahead before Danny Lennon was forced into an early change for the Paisley strugglers with Paul McGowan forced off through injury to be replaced by former Rangers player Gregg Wylde after 21 minutes.
Sutton struck to double Motherwell's lead (27) and St Mirren defender David McGregor was quick to beat the English striker to the ball as he looked set to add a quick third.
Thompson, at the heart of everything good for the hosts, headed just wide while McGregor headed McLean's deep free-kick over before the former Rangers man finally reduced the deficit, slotting home a knockdown from a corner (42).
Gunnar Nielsen punched an early St Mirren deadball clear after the restart, ahead of Jason Naismith's deflected shot wrong footing him but falling just the wrong side of the Motherwell goal.
Nielsen stopped well from Naismith as Saints found the ascendancy and then pushed away Thompson's goalbound effort.
Ainsworth forced a great save from Saints keeper Christopher Dilo before 'Well
forward Craig Moore passed up a great chance to make it 3-1, dragging well wide from 16 yards with 18 minutes to go.
McLean struck an equaliser (86), after McManus was adjudged to have handled in the box, before Thompson won it much to the delight of the home fans (87).