Napoli needed only a draw to qualify but Carlo Ancelotti's men went down to a narrow defeat, Salah once again proving the Liverpool hero.
After his hat-trick at Bournemouth at the weekend, the Egypt superstar scored the only goal with a magnificent individual effort, beating two Napoli defenders with a stunning turn of pace before finishing from a tight angle.
Napoli had beaten Liverpool 1-0 at home earlier in the group stage to put itself in control of their destiny but the Serie A side could not find a decisive equaliser, Jose Callejon firing over and Alisson brilliantly denying Arkadiusz Milik in the closing stages.
Salah and Marek Hamsik wasted early chances before the first major flashpoint, Virgil van Dijk booked for catching Dries Mertens on the ankle after winning the ball with a strong tackle.
Liverpool had the ball in the net when Trent Alexander-Arnold squared for Sadio Mane to tap in, but the Senegal forward was offside and the goal was disallowed.
The Reds took the lead in the 34th minute, though, Salah spinning away from Mario Rui to run on to James Milner's pass, then brilliantly beyond Kalidou Koulibaly to finish well through David Ospina's legs.
Salah almost added a second shortly after the restart but aiming for Ospina's near post he could only pick out the side netting, with Raul Albiol then heading a corner at the other end straight at Alisson.
Ospina denied both Salah and Mane in a frantic finale, the latter also firing wide a one-on-one chance to clinch the points in added time.
Napoli had chances to snatch qualification but Callejon blazed over Lorenzo Insigne's inviting cross at the back post, while Milik fired straight at Alisson when he should have scored.