The mercurial Argentine put his side into the lead twice before Zlatan Ibrahimovic wrapped up the points at the death to regain BarcaÃ¢â‚¬â„¢s five-point lead at the La Liga summit following RealÃ¢â‚¬â„¢s early evening win over Almeria.
Deportivo had reigned victorious in eight of their previous 12 fixtures Ã¢â‚¬â€œ sitting fifth in La Liga Ã¢â‚¬â€œ prior to their hosting of the champions and proved hard to break down.
Barca began in familiar probing fashion but failed to create an opening until the 15th minute when Dani Alves curled in a cross for Ibrahimovic to rise high and meet before heading tamely into the arms of Daniel Aranzubia in the Deportivo goal.
The goalkeeper faced a tougher task on 21 minutes after Messi jinked past three defenders to unleash a low drive towards goal, but was a match to the effort and turned it wide with his legs for a corner.
The Catalans were knocking on the door and it finally opened on 27 minutes.
Messi received the ball on the periphery of the 18-yard box and swiftly turned onto his favoured left foot before drilling the ball with venom into the bottom corner.
The recipient of the this yearÃ¢â‚¬â„¢s Ballon dÃ¢â‚¬â„¢Or was again involved on 36 minutes after sliding Ibrahimovic through on goal with a beautifully-weighted pass.
The elegant SwedeÃ¢â‚¬â„¢s touch unusually eluded him as he looked to round the goalkeeper and Aranzubia was able to push the ball from danger.
Barca appeared destined to head into the break with a deserved lead following a master-class in possession football, but Deportivo snatched an equaliser after a comedy of errors on 39 minutes.
Aranzubia launched a free-kick towards the Barca backline which Sergio Busquets could only glance into his own 18-yard box after losing his bearings and Deportivo striker Adrian darted in front of the defenders to head goal-wards.
An exposed and backtracking Victor Valdes allowed the ball to slip through his hands and over the line to the jubilation of the home fans.
The second half proved evenly contested and Deportivo looked set to extend their impressive record of suffering only three defeats in their 17 meetings with Barcelona inside the Estadio Riazor.
Barca left it late but turned on the style as the game approached the final 15 minutes Ã¢â‚¬â€œ taking the lead for a second time shortly after with a beautifully crafted goal.
A myriad of passes ended with second-half substitute Pedro chipping the ball across goal from the by-line for the diminutive figure of Messi to advance on unmarked and direct into the far corner with his head from eight yards.
The ArgentineÃ¢â‚¬â„¢s ninth goal in La Liga looked set to clinch an important three points for Pep GuardiolaÃ¢â‚¬â„¢s side until Deportivo threatened to level the scores for a second time with only three minutes left on the clock.
Jose Guardado broke the offside trap and drove forward before attempting to search out the unmarked Bodipo at the far post but his pass was too heavy and, to BarcaÃ¢â‚¬â„¢s relief, ran out for a goal kick.
Barca responded to the scare by putting the result out of sight with another incisive move.
Andres Iniesta found Eric Abidal as he surged forward on the left flank and the French full-back played a first-time ball across the 18-yard box for Ibrahimovic to power past the helpless Aranzubia and into the corner with the inside of his foot.
It was another display of the prolific strikerÃ¢â‚¬â„¢s abundant technique and his tenth La Liga goal brought the games action to a close and the three points back to the Camp Nou.
Deportivo: Aranzubia, Pablo, Colotto, Lopo, Filipe, Sergio, Tomas (Bodipo, 83), Rodriguez, Guardado (Alverez, 87), Mista, Adrian (Juca, 63)
Barcelona: Valdes, Dani Alves, Puyol, Pique, Abidal, Busquets, Xavi, Iniesta (Keita, 89), Messi, Ibrahimovic, Henry (Pedro, 70)
Man of the Match: Lionel Messi Ã¢â‚¬â€œ Scored two vital goals and was an absolute joy to watch.
MORE: Man United latest news
MORE: Arsenal latest news
MORE: Chelsea latest news
MORE: Liverpool latest news