Stephen Mallan converted a penalty to give the Buddies the lead after Darren Cole had fouled Calum Gallagher.
Liam Buchanan quickly levelled for Livi but Shankland's strike from outside the box had the visitors ahead again by half-time.
Jordan White poked home for the hosts only for Shankland to fire an impressive volley and settle the match.
Lawrence Shankland scored twice as St Mirren beat second-bottom Livingston in the Scottish Championship.