Dundee 2 St Johnstone 1
Sofien Moussa headed a late winner as Dundee manager Neil McCann had the last laugh following his simmering dispute with St Johnstone counterpart Tommy Wright.
Hearts-bound striker Steven MacLean marked his 200th game for St Johnstone with an 85th-minute strike which looked set to earn a point for the visitors at Dens Park.
But Moussa headed home three minutes later from Cammy Kerr's free-kick to hand Dundee three precious points in their quest to secure Ladbrokes Premiership safety. The Tunisian forward was also credited with the first-minute goal which sent Dundee on their way to a 2-1 victory.
The build-up to the Tayside derby had been dominated by ongoing tensions between both mangers following a disagreement in the immediate aftermath of St Johnstone's 4-0 win at Dens Park six weeks ago. There were six bookings this time but no major flashpoints.
McCann was in the stand after ultimately being handed a one-game ban for his part in a tussle with goalkeeper Zander Clark, who came into the Saints team after serving a two-match suspension.
The Dundee boss declared on the eve of the game that he had no intention of speaking to Wright after the Saints boss claimed his club had come out on the right side of the affair, and added that the Northern Irishman was not welcome in my room either''.
Wright responded with a wave as he was jeered by the home fans in the 5,592 crowd on his way to the dugout but his team found themselves behind moments later.
O'Hara hit Kevin Holt's free-kick off the inside of the post and Moussa made sure the ball went over the line, although it may have already done so.
The visitors showed a decent response as they pinned Dundee back. Joe Shaughnessy shot over after a free-kick into the box and Elliot Parish made a brilliant close-range stop after Matty Willock turned and shot.
But Dundee came back into it late in the half. Craig Wighton had an effort deflected wide after drifting inside several players on his first start of the season following a serious knee injury.
Simon Murray shot just wide after Glen Kamara's cutback and then forced a decent near-post save from Clark as Dundee kept their opponents at bay in the early stages of the second half.
The hosts had an escape in the 64th minute when Shaugnessy's acrobatic volley bounced off the bar from 12 yards out.
Murray had a free-kick pushed away by Clark but Dundee paid for sloppy defending as Holt and Kerr failed to clear and MacLean slotted home from 12 yards.
But Moussa delivered a perfect riposte as Dundee moved six points clear of bottom club Ross County.