World Player of the Year Messi and five Spanish internationals out of the starting lineup at the Nou Camp.
Chile forward Alexis Sanchez put them in front in the 38th minute when Depor goalkeeper Daniel Aranzubia could only palm his powerful downward header into the roof of the net.
Spain's record scorer David Villa, still not back to his best after breaking his leg at the end of 2011, had earlier squandered a golden chance and made way for Messi with about half an hour left.
The Argentina forward fluffed one effort five minutes from time but drew gasps from the home crowd in the 88th minute when he exchanged passes with Alexis and dinked a delightful chip over the onrushing Aranzubia into the net.
It was Messi's 40th goal of the la Liga campaign, his 51st in 41 appearances in all competitions and the 17th straight league match in which he has scored, which Barca said was a world record.
The club said on its website (www.fcbarcelona.es) that Messi had overhauled Polish forward Teodor Pewterek, who scored in 16 straight outings for Ruch Chorzow at the end of the 1930s.
Messi has 11 matches in which to beat his La Liga record tally of 50 goals from last season.
Assistant Barca coach Jordi Roura, standing in for Tito Vilanova while he has cancer treatment in New York, said beating Depor was the best way to prepare for the Milan match.
"We played with a lot of intensity and had a lot of presence in their penalty area but they are two completely different competitions," he told a news conference.
"The players seem in good shape and we will do everything humanly possible to get past Milan," he added.
Barca went into the game following three defeats in their last four outings including a 2-0 loss in their Champions League last-16, first leg tie at Milan last month and bitter reverses to arch-rivals Real Madrid in the King's Cup and La Liga.
Their return to winning ways and a first clean sheet in 14 games puts them on 71 points from 27 of 38 matches, with second-placed Atletico Madrid on 57 ahead of their home fixture against Real Sociedad on Sunday (2000 GMT).
Champions Real, in third spot two points behind their city rivals and on a high after securing a place in the Champions League quarter-finals by beating Manchester United, visit relegation-threatened Celta Vigo on Sunday (1800).
Malaga were denied a morale-boosting win before their Champions League game against Porto on Wednesday when they were held to a 1-1 draw at Real Valladolid earlier on Saturday.
The Qatari-owned club must overturn a 1-0 deficit to reach the Champions League quarter-finals on their competition debut.
Coach Manuel Pellegrini initially left playmaker Isco on the bench and did not use Joaquin for the game at Valladolid's rain-lashed Jose Zorrilla stadium.
Argentine defender Martin Demichelis nodded Malaga ahead in the eighth minute before Angola striker Manucho headed the equaliser four minutes before halftime.
The draw leaves Malaga on 44 points in the fourth qualification spot for next season's Champions League.
Valencia can move on to 45 points with a win at Athletic Bilbao on Sunday (1100 GMT).
Rayo Vallecano improved their chances of securing a lucrative place in Europe next season when goals from Alejandro Dominguez and captain Piti gave the modest Madrid-based club a 2-0 win at home to Espanyol.
The victory lifted Rayo, who have 41 points from 27 matches, to eighth. Barcelona-based Espanyol are 13th on 32 points, three behind 10th-placed Valladolid.
Sevilla's European bid suffered a setback when they lost 2-1 at struggling Real Mallorca in the late kickoff.
Sevilla stay 11th on 35 points, while Mallorca climbed above Celta to 18th on 24 points, seven ahead of Depor.