However, Jon Obika pulled one back for St Mirren three minutes later to leave the match hanging in the balance until the full-time whistle.
The three points helped to cement the home side's place in the top-six of the Ladbrokes Premiership and left the Buddies just four points above bottom-side Hearts.
Livingston seemed eager to atone for their back-to-back defeats to Ross County in the league and Inverness in the cup as they started on the front foot.
Goalkeeper Robby McCrorie did have to look smart to prevent Obika from latching onto a long ball just a minute in but thereafter the home side took control.
Moments later, Jack McMillan's curling cross almost picked out Scott Robinson and from the resulting corner Jon Guthrie's header had to be cleared off the line by a St Mirren defender.
In the 13th minute, the Lions pushed for the opener again. McMillan's cross was knocked back into the danger area by Ciaron Brown but Guthrie blazed his shot over when he should have done better.
A free-kick from Aaron Taylor-Sinclair, driven low under the defensive wall, then almost caught out Vaclav Hladky but the St Mirren keeper held it at the second attempt.
Midway through the half, the visitors threatened for the first time.
A Cammy MacPherson corner from the left picked out Conor McCarthy in space at the far side of the six-yard box but McCrorie held the defender's header.
And with 11 minutes to go to the break, Livingston took the lead in controversial fashion.
Dykes raced onto a chipped pass over the defence from Craig Sibbald and went down in the box under pressure from McCarthy.
St Mirren were incensed by referee David Munro's decision to point to the spot but Lawless kept his cool to send Hladky the wrong way.
Livingston lost captain Marvin Bartley to injury at the interval but his replacement, Keaghan Jacobs, made an instant impact as he set up the home side's second.
The midfielder sliced open the Buddies defence with a slide-rule pass to find the running Dykes and he slotted beyond Hladky.
St Mirren found a response, however, as they pulled one back just four minutes later.
MacPherson picked up space inside the Livingston half and threaded a superb ball beyond the home rearguard. Obika won the race with Brown and sent his shot beyond the advancing McCrorie.
Hladky's foot then denied Robinson when the Lions attacker was sent clear through on goal before Livi almost grabbed a third.
Sibbald's corner from the right picked out the rising Dykes but his header crashed back off the upright and St Mirren could not find a leveller as they pushed hard in the closing stages.