The home side, who had narrowly lost their last two matches against Ospreys and Blues, had kept themselves in contention thanks to tries from wing Steffan Evans and full-back Michael Collins. Aled Thomas also added two penalties and a conversion before replacement fly-half Shingler won the game in the 78th minute.
Connacht, who earned a losing bonus point, scored one try through wing Matt Healy, while centre Craig Ronaldson kicked eight points and fly-half Jack Carty booted over two late penalties.
Slick handling from Scarlets centre Regan King sent the hosts through on an early attack and he also drew an illegal shoulder charge from Bundee Aki in the ninth minute. The Connacht centre was sent to the sin bin for his troubles.
Despite being down to 14 men it was the visitors who went closest to breaking the deadlock, with number eight Eoghan Masterson going over before TMO Paul Adams adjudged a knock on and disallowed the try.
On 23 minutes it was King's turn to be yellow-carded for killing ball at a ruck in Scarlets' 22. From the offence Ronaldson opened the scoring with a penalty.
Five minutes later Connacht were 10-0 ahead after making the most of the extra man as Healy ran in from 70 metres after Scarlets lost possession in the opposition 22.
Thomas finally got the hosts off the mark four minutes before the end of the half, but there was still time for Connacht to put pressure on.
Moments before the interval Healy thought he had his second try of the afternoon, but TMO Adams was once again on hand to deny the visitors for another knock-on to leave their lead at 10-3.
The Scarlets launched a concerted comeback after the break. Another Thomas penalty opened the scoring in the second half, before left wing Evans slid into the left corner after good work from King and Parkes. Thomas was on target again with the conversion to put the hosts in front for the first time at 13-10.
But Scarlets were only in the lead for three minutes before a Ronaldson penalty drew Connacht level at 13-13.
DTH van der Merwe and Parkes combined in defence to deny Connacht and, after Scarlets swept up field, a fine pass from replacement scrum-half Rhodri Williams allowed King to put Collins over down the left. Thomas missed the conversion this time but Scarlets led 18-13 on 61 minutes.
Connacht squeezed back in front with two Carty penalties - the second only three minutes from the end - but the hosts would not be denied.
Replacement prop Ronan Loughney became the third player sent to the sin bin by referee Marius Mitrea for an illegal tackle, which allowed Shingler to kick the winning points.