The Wales fly-half, who minutes earlier had missed a penalty, coolly slotted from the 22 to sneak a 22-20 success for the home side.
The Scarlets led 17-16 at half-time thanks to tries by Wales internationals Gareth Davies and Ken Owens.
Continue reading below…
However, the Dragons, whose first-half try came from Rhodri Williams, struck late to dent their visitors’ play-off challenge.
The full-back slid in after just nine seconds but the TMO deemed he had knocked on.
Halfpenny did soon open the scoring, albeit with a penalty, only for Dragons fly-half Davies to knock over two for a 6-3 lead in the ninth minute.
Davies landed a third penalty but the Scarlets took advantage of a yellow card shown to home lock Matthew Screech to stretch into a 17-9 lead after 31 minutes thanks to tries by a pair of Wales internationals.
The Dragons needed to respond and they did, with captain Rhodri Williams going under the posts from close range after full-back Will Talbot-Davies went close and fly-half Davies converting to make it 17-16 to the visitors at the break.
The Scarlets, who lost loosehead Wyn Jones to the sin bin at the end of the first half for his part in a scuffle, came close to stretching their lead when Ryan Lamb’s cross-kick found Johnny McNicholl in space down the right only for the wing to spill the ball with the line at his mercy.
The second half was a more cagey affair with plenty of mistakes in the torrential Newport rain and it remained a tense, one-point game going past the hour mark.
The tense tussle went the way of the Dragons in the 74th minute when Davies punished an offside only for the Scarlets to respond almost immediately through Halfpenny after a lineout offence.
Davies had another shot at goal after Moriarty was taken out off the ball but he pulled his long-range effort from the tee. He made no mistake at the death.
Sign up to our mailing list here and we’ll keep you up to the minute with weekly updates from the world of rugby.