Livingston leapfrogged Ayr United into second place in the Scottish Championship with victory in a Somerset Park thriller.

The relegated side raced into two-goal lead with a magnificent strike from Robbie Muirhead and a calm finish from Scott Pitman.

Connor McLennan pulled one back before the break with a tap-in after Jerome Prior produced a fabulous save from a George Oakley header.

Ayr probably deserved a draw on their second-half showing, but there were no further goals as Livingston hung on.