The defeat was Barcelona's first in the league since the start of October and while they remain top of the table, Real Madrid are now just one point behind Luis Enrique's side and have two games in hand.
Neymar missed out for Barcelona due to an adductor problem, while Rafinha was also ruled out through injury as head coach Enrique made five changes to the team that started Wednesday's Champions League clash with Paris-Saint Germain.
As for Deportivo, head coach Pepe Mel shuffled his pack following the 1-1 draw with Real Betis on Wednesday, with Joselu, Fernando Navarro, Bergantinos, Bruno Gama and Raul Albentosa all coming into the XI. Florin Andone and Pedro Mosquera, meanwhile, missed out through suspension.
Despite Barcelona dominating the ball in the opening 10 minutes, the first shot of the match actually came from Deportivo - on-loan Stoke City forward Joselu testing the handling of Marc-Andre ter Stegen with a strike from just outside the box.
As the rain continued to fall in La Coruna, Barcelona struggled to move through the gears and Mel's work since arriving at Deportivo was clear to see as the home side remained well-drilled in defensive areas.
It took until the 28th minute for Barcelona to register their first attempt on target, and Luis Suarez's header from a deep free kick landed into the arms of Deportivo goalkeeper German Lux. Moments later, Andre Gomes attempted to pick out the top corner of the home side's net from a narrow angle, but the ball flew over the crossbar.
Barcelona's best chance of the first period came 10 minutes before the interval when Sergi Roberto found himself free inside the Deportivo box, but instead of shooting, the Spaniard attempted to pick out the waiting Luis Suarez, and Lux was on hand to cut out the low cross.
Joselu came close to sending Deportivo ahead in the latter stages of the first period when he angled one towards the bottom corner, but Ter Stegen was on hand to save. The Barcelona goalkeeper was at fault from the resulting set piece though as Joselu smashed home from close range to send Deportivo ahead after the German had fumbled a loose ball.
Andres Iniesta and Ivan Rakitic both went through energetic warm-ups at the interval, but Enrique resisted the temptation to make any half-time changes as he trusted those on the field to turn things around.
That trust was well-placed as less than one minute into the second half, Barcelona were level when Luis Suarez smashed the ball past Lux after a loose ball had fallen perfectly for the striker inside the Deportivo box.
The home side had two good chances to regain the lead in the 54th minute, but Bergantinos just failed to meet a cross from Joselu, before Faycal Fajr had a powerful strike deflected over Ter Stegen's crossbar.
Enrique's response to the pressure from Deportivo was to introduce both Iniesta and Rakitic, but it remained a very even contest entering the final 30 minutes of action on a rainy afternoon in La Coruna.
Both goalkeepers were called into action past the hour as Ter Stegen kept out a strike from Bruno Gama, before Lux did well to save from Denis Suarez, who had found space inside the Deportivo box.
Incredibly, Deportivo regained the lead in the 74th minute when Bergantinos rose highest inside the Barcelona box to head a corner past Ter Stegen, leaving Barcelona facing their first league defeat since October.
The visitors came close to levelling 10 minutes from time from Luis Suarez fired a low Roberto cross towards the bottom corner, but Lux was on hand to save as Mel's side kept one goal ahead of the Spanish champions.
Barcelona continued to press for a leveller and Gerard Pique just failed to collect a deep Messi cross inside the Deportivo box, before Roberto sent the ball over the crossbar after making contact on a cross from Luis Suarez.
Messi had the chance to equalise from a 25-yard free kick in second-half stoppage time, but the Argentine fired into the stands as Deportivo, who missed a chance to seal all the points when Fajr went through one-on-one with Ter Stegen late on, recorded their first win over Barcelona since 2008.
Next up for Barcelona is a home game against Valencia on March 19, while Deportivo, who are now unbeaten in their four league matches since Mel took charge, host Celta Vigo on the same day.