Last updated on .From the section Scottish Premiership

By Jonathan Sutherland BBC Scotland at the Tony Macaroni Arena

Scott Wright inspired Dundee as they came from behind to beat 10-man Livingston and move out of the Scottish Premiership's bottom two.

Shaun Byrne was dismissed for a challenge on Andreas Hadenius moments before Craig Halkett fired the hosts in front - Livi's first goal of 2019.

Andrew Nelson's flicked header from Wright's corner levelled matters.

And the forward's impressive free-kick ensured Dundee moved above Hamilton Academical on goal difference.

Jim McIntyre's side also stretched their advantage over bottom side St Mirren to five points.

Gary Holt's Livingston remain ninth and without a win since mid-December.

First-half profligacy doesn't cost Dundee

Dundee had several decent chances early on, with Nelson firing over from 20 yards before squandering a fantastic opportunity with a free header from six yards that flew over the bar.

There would be an even better opportunity for Wright as the ball arrived at his feet six yards from goal. It looked like being a certain goal but he shot high over the bar.

Byrne saw red before the quarter-hour mark

Livi hit the post through Ricki Lamie's cross and then lost Byrne on 14 minutes for a high boot on Andy Dales.

However, the hosts soon found themselves in front as Alan Lithgow's throw-in was flicked to the back post by Declan Gallagher and captain Halkett struck.

Dundee maintained the pressure but kept failing to hit the target, Dales squandering an opportunity just before half-time after being played clean through.

The away side would finally take their chance early in the second period. Wright crossed into the box and there was Nelson to loop a header into the net and score his fourth Dundee goal in six appearances.

Dundee then almost took the lead when Hadenius' replacement, Paul McGowan, was played through into the box but his shot whistled just wide.

Livingston's Ryan Hardie curled narrowly off target and Steven Lawless was booked for simulation following Jesse Curran's challenge in the Dundee box before Wright's moment of sublime brilliance - the Aberdeen loanee stepping up to bend a perfect free-kick into the top corner.

Visiting goalkeeper Seny Dieng pulled off a superb double save to deny first Halkett then Chris Erskine, and that proved enough to secure Dundee the points.

Massive win for Dundee - analysis

Dundee had only won once in their previous 12 games, so this victory was massive.

Not only was it deserved on balance of chances it would allow the Dark Blues to leapfrog Hamilton.

For Livingston that is now nine games without a win in all competitions, six of which have been defeats.

Livi 'denied stonewall penalty' - reaction

Livingston head coach Gary Holt: "We should have a stonewall penalty at a crucial point in the game for Jesse Curran's challenge on Steven Lawless. It's something that's cost us, it's cost the boys. It's cost them a chance to win the game. How you can book him for diving is beyond me.

"I didn't see Shaun Byrne's red card initially. I've had a look at it just from one angle so far. I think it's maybe a yellow but I'd need to see it from other angles."

Dundee manager Jim McIntyre: "I thought it was a stonewall red card for Shaun Byrne. I thought it was a really poor challenge at the time. It was quite high and reckless. I thought it was clumsy from Jesse Curran on Steven Lawless. I'd need to see it again.

"It was a goal fit to win any game from Scott Wright. We were delighted to come back. We lost a really poor goal. We showed a great reaction. Overall, I think we deserved to win the game."