The Belgian was given a huge assist from Jordan Pickford who pushed a ball that may have been going over his crossbar onto the head of the substitute, who was making his first Premier League appearance for Liverpool since August 2017.
The two goalkeepers exchanged crucial saves, with Alisson Becker spreading himself to block a header from Andre Gomes, who had seemed destined to score from four yards out when Theo Walcott directed Bernard's cross perfectly into his path. Joe Gomez backed up the Brazilian by reacting quickly to clear the loose ball off the line.
Pickford responded with an equally good stop to deny Xherdan Shaqiri on 34 minutes, making himself big to divert the shot from 10 yards out behind for a corner, with Salah having sent the Swiss international through one-on-one with the keeper.
Salah had fewer touches of the ball in the first half than his own goalkeeper, but it took the Egyptian only three minutes of the second period to fashion a chance for himself, turning on the edge of the box and bending a low shot just wide of Pickford's post.
The Toffees did not carry as much of an attacking threat in the second half, but Liverpool continued to create chances including a glorious one for Mane on 53 minutes. Roberto Firmino released the Senegalese, who sliced wide on his left foot 10 yards from goal.
Mane looked the most likely to break the deadlock but could not trouble Pickford with an attempted curler from 25 yards.
Ademola Lookman was bright off the Everton bench and his driving run set up Bernard for a 67th-minute shot which the Brazilian fired wide.
Origi's chance to be the match-winner appeared to have passed him by when he hit the crossbar two minutes from time, flicking his right foot hopefully at a bouncing ball inside the six-yard box after Van Dijk had won the initial header from a corner.
However, the forgotten forward was handed the points on a plate by Pickford in the most unusual circumstances. Van Dijk's skied volley appeared to be flying into the stands but dropped towards the Everton goal, and Pickford made a mess of clearing it to hand Origi a derby moment to remember.
The late triumph is Liverpool's 11th win from 14 league games this season and keeps them within two points of City.
LIVERPOOL (4-2-3-1): Alisson; Alexander-Arnold, Gomez, Van Dijk, Robertson; Wijnaldum, Fabinho; Shaqiri (Keita, 71'), Firmino (Origi, 84'), Mane; Salah (Sturridge, 75')
EVERTON (4-2-3-1): Pickford; Coleman, Keane, Mina, Digne; Gomes, Gueye; Walcott (Lookman, 63'), Sigurdsson (Zouma, 90'), Bernard (Calvert-Lewin, 89'); Richarlison