Ojamaa opened the scoring midway through the first half at Fir Park before Jody Morris levelled on the stroke of half-time.
The Estonian restored the hosts' lead on 65 minutes and Keith Lasley doubled their advantage 10 minutes later with a fantastic drive from 25-yards.
Francisco Sandaza netted from the penalty spot with 10 minutes remaining but Motherwell held out for an important three points.
The hosts made a bright start to the match and in the opening minute Jamie Murphy's long-range drive drifted inches past the post.
St Johnstone created their first opening after 10 minutes when Morris fired well wide of the target, following good work by Sandaza.
Marcus Haber missed a glorious opportunity to head the visitors ahead on 13 minutes when he leapt unmarked to meet Dave MacKay's cross, but the Canadian's attempt went harmlessly over the bar.
After a difficult opening to the match, St Johnstone were beginning to seize the initiative and Darren Randolph in the home goal had to be alert to handle a dangerous Sandaza free-kick.
Motherwell took the lead against the run of play on 22 minutes, Nicky Law who slipped the ball through to Henrik Ojamaa who hammered the ball across Peter Enckelman and into the bottom left-hand corner.
The hosts almost doubled their lead two minutes later when Steven Hammell's rifled effort struck the top of the Saints bar with Enckelman beaten.
St Johnstone came agonisingly close to levelling the game on 36 minutes, Tim Clancy clumsily took down Sandaza and from the resulting free-kick Liam Craig struck the underside of Randolph's crossbar.
The away side continued to search for a leveller and seven minutes before half-time Croft forced an excellent save from Randolph after neat build-up play between Sandaza and Murray Davidson.
Sandaza attempted to seize on the rebound but instead lunged into a dangerous tackle on Clancy - earning himself a yellow card.
St Johnstone grabbed the equaliser their play merited a minute before the break when Lee Croft did well to find Morris, who unleashed an unstoppable effort beyond Randolph.
Craig tested Randolph in the opening minutes of the second half when he raced onto Sandaza's flick-on and fired a low shot which the former Charlton goalkeeper did will to hold.
St Johnstone continued to look the more likely to take the lead and Randolph saved well from Murray Davidson before making an excellent stop from Sandaza's close-range attempt on 57 minutes.
Motherwell took the lead on 65 minutes with their first effort of the second half, Ojamaa looked to have miscontrolled Tom Hateley's pass but the Estonian recovered to fire beyond Enckelman.
After regaining the lead, Motherwell began to show more of an attacking threat and Hateley flashed a shot well wide after good build-up play between Omar Daley and Ojamaa.
The hosts doubled their advantage with 15 minutes remaining when Keith Lasley ended a lightning-fast breakaway with a 25-yard effort which looped over Enckelman.
Murray Davidson blazed an effort over the bar from six-yards as St Johnstone attempted to find a way back into the game and they were handed the perfect opportunity when referee Calum Murray pointed to the spot when Davidson was felled by Lasley.
From the resulting penalty Sandaza rifled the ball into the roof of the net to set up an exciting conclusion to the match.
The visitors were unable to breach the Motherwell defence however and the hosts held out for the victory.