Messi - who hadn't scored since his single goal in the reverse fixture between the two teams - grabbed a brace to ensure Barcelona progressed from Group H.
The hosts took the lead on 29 minutes from the spot after Ignazio Abate was caught on the wrong side of Neymar and the defender brought down the Brazilian with his arm. Messi stepped up to power the ball confidently into the middle of the net.
But on the stroke of half-time Milan gave themselves a lifeline when Kaka rolled back the years with a surging run and his determination was rewarded as his cross was poked into the back of the net by Pique.
Despite a resilient fight back from the visitors, Messi sealed the three points with a fantastic goal when he played a one-two with substitute Cesc Fabregas before coolly lobbing the ball over the advancing Christian Abbiati.
PRE-MATCH - Tonight's big surprise is the exclusion of Mario Balotelli from Massimiliano Allegri's selection. The controversial Italian has been benched for tonight's match as Milan look to get one over on their European rivals.
28' - PENALTY TO BARCELONA - Abate gets caught the wrong side of Neymar and puts his arm in front of the Brazilian who falls to ground.
29' - BARCELONA GOAL - And the drought is over! Messi fires a powerful penalty straight down the middle to put his side in front.
39' - BARCELONA GOAL - And this is too easy for the hosts. Busquets heads home Xavi's free-kick delivery.
45' - MILAN GOAL - And Milan are back in this game! Kaka's bursts forward on the wing and his cross is deflected into the net.
83' - BARCELONA GOAL - And it's game over. Messi plays a one-two with Fabregas before coolly lobbing the ball over the advancing goalkeeper.
Barcelona have won their last three Champions League home games against AC Milan, scoring 10 goals in the process.
AC Milan have won only three of their last 17 Champions League away games and only one of their last 12 Champions League away games in Spain.
Lionel Messi has scored six of Barcelona’s nine goals so far this season. He scored his 64th and 65th Champions League goals tonight.
Messi has now scored five plus goals in seven successive Champions League seasons, no other player has done it more than five. TALKING POINT: So much for a crisis. Messi's failure to score in his last four games had some claiming the Argentine's best days were over. He responded tonight by grabbing a brace as he scored his fifth and sixth goals of the competition. MAN OF THE MATCH: Lionel Messi (Barcelona): You can't look past Messi who put in a magnificent performance tonight. He caused the Milan defence problems all night and he could easily have added to his two goals.
MATCHCAST: PLAYER RATINGS AND FULL STATS PLAYER RATINGS
Barcelona - Valdes 6, Alves 6, Pique 6, Mascherano 8, Adriano 7, Xavi 7, Busquets 8, Iniesta 7; Alexis 7, Messi 9, Neymar 9. Subs: Song, 6 Fabregas 7, Pedro 6,
Milan - Abbiati 7, Abate 6, Zapata 5, Mexes 7, Emanuelson 6; de Jong 8, Montolivo 6, Muntari 6, Kaka 7, Poli 5, Robinho 5. Substitutes - Matri 6, Balotelli 8.
MATCH IN A TWEET