The hosts looked set to move into second position after Allan Campbell's opener at Fir Park.
However, goals inside the last 15 minutes from substitute Brian Graham and Ross Stewart gave the Staggies an unexpected three points - and a bad day for the hosts was compounded by the dismissal of Jake Carroll in between the breakthroughs.
The hosts almost grabbed the lead in emphatic style in the sixth minute. Left-back Carroll stepped up to take a free-kick from 25 yards out and his beautiful curling effort flew just over the bar with goalkeeper Ross Laidlaw rooted to the spot.
The visitors countered when Billy McKay's flicked header from Ewan Henderson's free-kick sailed narrowly wide.
Celtic loanee Henderson caused havoc with his excellent deliveries from dead balls and after another pinpoint corner, McKay's acrobatic effort was gathered by goalkeeper Mark Gillespie in the 12th minute.
It was an end to end start to the game and Motherwell went close through James Scott six minutes later - but his powerful effort from a tight angle went wide.
Motherwell thought they had taken the lead in the 22nd minute but Declan Gallagher's header from a long throw was disallowed by referee Alan Muir for a foul on Keith Watson.
The hosts' feeling of injustice wasn't limited to Carroll's red card or the disallowed goal, they had a strong claim for a penalty on 57 minutes when Watson appeared to handle in the box - but Muir waived play on.
The hosts broke the deadlock just past the hour mark with a brilliant free-flowing move finished off by Campbell.
Devante Cole picked up the ball and drove with purpose past two defenders before feeding it to Scott, who cushioned the ball perfectly for Campbell to curl left-footed beyond Laidlaw from the edge of the box.
However, the visitors had carried a threat all afternoon and Graham equalised three minutes after his introduction, showing great composure to slide the ball past Gillespie after receiving a pass from Michael Gardyne.
Motherwell's afternoon quickly deteriorated as Carroll was shown a red card five minutes later following two needless bookings in quick succession. Both fouls were on Stewart and whilst the first was deserved for a rash tackle, the second looked slightly harsh as Well manager Stephen Robinson remonstrated with the officials.
The visitors made the extra man count in the 87th minute when Stewart decided the contest, heading home his eighth goal of the season from close range after a stunning cross from Richard Foster.