An action-packed first half at Camp Nou saw Barca take a three-goal lead, before Lorenzo Insigne pulled one back from the spot in stoppage time.
Clement Lenglet's ninth-minute header broke the deadlock, with Messi netting an exquisite second prior to winning a penalty which Luis Suarez converted.
Insigne's spot-kick gave Napoli hope, but Barca had enough to book their place in the last eight, where Bayern Munich await.
Dries Mertens clipped the woodwork inside two minutes but Barca swiftly took control – Lenglet heading home unmarked from Ivan Rakitic's inswinging corner, with the goal standing after a VAR check for a possible foul on Diego Demme.
Further punishment followed when Messi bundled his way through a crowd of defenders and, despite an untimely slip, he curled a wonderful finish beyond David Ospina.
It appeared Barca had gone 3-0 up by the half-hour mark, only for Messi to have a second goal ruled out for handball, yet Barca had their third when Suarez scored from the spot after Kalidou Koulibaly clumsily kicked Messi.
Napoli were handed a lifeline two minutes later, however, with the referee harshly deeming Rakitic to have fouled Mertens – Insigne converting the resulting penalty.
Not so fast! Lorenzo Insigne gets Napoli on the board before half to give hope to the Italian side. pic.twitter.com/ddNikOnTXT— Champions League on CBS Sports (@UCLonCBSSports) August 8, 2020
Insigne could have doubled his tally early in the second half, but failed to test Marc-Andre ter Stegen with a close-range header.
Arkadiusz Milik looked to have made an instant impact after his introduction from the bench late on, only for his header to be disallowed for offside as Barca secured their place in Portugal with minimum fuss.
What does it mean? Barca still have hope
It has been a dismal season on the domestic front for Barca, but their hopes of a sixth Champions League title remain intact.
However, an imperious Bayern side will present an altogether different challenge than Gennaro Gattuso's side after their 7-1 aggregate victory over Chelsea, and the Blaugrana will have to display a quality which has often been lacking this term in order to progress further.
Messi turns on the magic to lift Setien
It has not been easy for Quique Setien since he was appointed in January, and the Barca boss could well have been under severe pressure had his side gone out on Saturday.
However, Messi turned on the style to quieten the doubters – at least for now.
Koulibaly found wanting
Raphael Varane made two calamitous mistakes for Real Madrid against Manchester City on Friday, and another of Europe's finest defenders struggled this time out.
Koulibaly seemed to go down easily in the build up to Barca's opener when Demme was pushed into him, while Messi got the better of him to win the penalty from which Suarez made it 3-0.
Bayern are Barca's opponents in the last eight, with the game to take place in Lisbon on Friday. Napoli, meanwhile, will turn their attention to next season.