Messi had not scored in his past three matches in La Liga but broke the deadlock against the Italian giants after half an hour from the penalty spot.
Sergio Busquets doubled Barca's lead 10 minutes later and although Gerard Pique's own goal gave Milan hope, Messi settled matters in the closing stages.
The result moves the Catalan club six points ahead of third-placed Ajax with a far superior goal difference, while Milan - who have endured their worst start to Serie A in 31 years - remain second in Group H.
Milan came into this clash desperate to put their domestic woes behind them but they seemed content to sit back and wait for the chance to counter-attack.
That allowed the Spanish champions to set the tone and while they predictably dominated possession, they struggled to break down their opponents in the early stages.
Neymar came close when he latched on to Messi's throughball, but the Brazilian's shot was blocked by Urby Emanuelson.
Milan goalkeeper Christian Abbiati sprung into action in separate Barca attacks to deny Neymar and Alexis Sanchez, who then narrowly failed to add the final touch at the far post from Adriano's low left-wing cross.
The breakthrough arrived on the half hour mark as Messi ended his goal drought from the penalty spot after Xavi had expertly chipped over the Milan defence for Neymar, who was tugged back in the area by Milan defender Ignazio Abate.
Messi then fired straight down the middle from the spot for his first goal in four games, with his last strike coming in the reverse fixture against Milan two weeks ago.
Riccardo Montolivo fired a warning shot to Barca, shooting narrowly wide from just outside the area as Milan sought a leveller.
However, they fell two behind in the 40th minute although they may feel hard done by as there was a strong suspicion of offside against goalscorer Busquets.
Xavi curled a wonderful free-kick in from the left wing allowing Spain team-mate Busquets to head past a helpless Abbiati.
Adriano then forced the Milan goalkeeper to tip over but the Rossoneri got themselves back into the match on the stroke of half-time.
Former Real Madrid midfielder Kaka dribbled past Dani Alves on the left wing and his cross cannoned off an unfortunate Pique and past Barca goalkeeper Victor Valdes, who had been a virtual bystander up until that point.
Under fire Milan boss Massimiliano Allegri sought to address the balance by bringing on Mario Balotelli on for the ineffective Robinho.
Barca still remained on top and only a good save from Abbiati prevented Andres Iniesta from doubling the home side's advantage once again.
Sanchez missed a glorious chance when he saw his shot from point-blank range excellently tipped away by Abbiati.
However, Messi settled matters seven minutes from time after exchanging passes with substitute Cesc Fabregas before chipping over Abbiati.