Tony Watt gave Motherwell the lead in the 61st minute following a set-piece but Saints turned the tie around inside 16 minutes at Fir Park.
With Danny McNamara absent, O'Halloran caused trouble for Motherwell all day from his wing-back position.
The victory extended St Johnstone's unbeaten run to 10 matches.
Saints looked the sharper team in the opening stages and continued to be more impressive in possession during the first half.
O'Halloran posted his intentions early on with a number of penetrating runs and centre-back Shaun Rooney followed suit down the right flank before cutting the ball back for Wotherspoon to fire wide.
Callum Lang played in Watt after a long ball but the former Saints striker shot weakly straight at Zander Clark.
St Johnstone's best chance of the half came just before the interval when Stevie May's flick set up Ali McCann but home goalkeeper Aaron Chapman stopped the midfielder's shot with his foot.
Saints came close just after the restart when Chapman got down to push Wotherspoon's shot wide.
Watt could not react quickly enough after Polworth's shot deflected into his path with Clark grounded but the striker was soon on target.
Ricki Lamie headed on Polworth's free-kick and Watt brushed off his marker and stabbed the ball home from 10 yards.
Chapman saved from Hendry just before the striker equalised in the 68th minute.
O'Halloran sprinted down the flank and delivered a low cross from the bye-line which Chapman tried to trap with his foot but only succeeded in setting up Hendry to net from close range.
O'Halloran soon repeated the feat, getting beyond the Motherwell defence and firing the ball across the goalmouth for Wotherspoon to claim the final touch from close range.
Grimshaw had a long-range strike comfortably saved but Motherwell could not carve out a clear-cut chance to take the game into extra-time and both May and Wotherspoon threatened to add to Saints' lead.