The scores were level at the break with Theo Fages and Matty Smith crossing for the visitors and Alex Mellor and Patrick Ah Van going over for Widnes.
Saints took the lead when Mark Percival kicked a penalty, after the Vikings had been penalised for offside.
That looked to be the winning score, but the hosts eventually made their pressure tell when Ah Van crashed over.
The New Zealander's second try of the night gave the hosts a first home win of the season, and they are now just one point off 11th-placed Huddersfield.
Victory will ease some of the pressure on coach Denis Betts, but his team did it the hard way.
They were much the better team in the first half but went in level at the break after individual errors contributed to them failing to add to their 12 points.
Saints had a Luke Thompson try ruled out by the video ref at 14-12 up, before Ah Van's decisive score gave Widnes a vital two points.
Widnes: Hanbury, Thompson, Bridge, Runciman, Ah Van, Mellor, Gilmore, Dudson, Johnstone, Buchanan, Houston, Dean, Gerrard.
Replacements: Whitley, Burke, J. Chapelhow, D. Walker.
St Helens: Bailey, Swift, Fleming, Percival, Grace, Fages, Smith, Richards, Lee, Amor, Taia, Wilkin, Thompson.
Replacements: McCarthy-Scarsbrook, Walmsley, Peyroux, Knowles.
Whitehaven v Halifax in the Challenge Cup fifth round is live on on Sunday, 23 April on Connected TV and online from 14:55 BST, along with live text commentary online.
Widnes Vikings claimed just their second Super League win of the season with a narrow victory over St Helens.