Fikayo Tomori opened the scoring for the home side in the right before the 30-minute mark when he side-footed a shot home after Liverpool keeper Alisson palmed a corner kick right into his path in front of the net to give Milan a huge first goal.
Divock Origi put Liverpool ahead shortly after the restart when a poor giveaway from the Milan defence sprang Sadio Mane into the area and his shot was blocked in the direction of the Belgian, who powered a header past Mike Maignan to make it 2-1.
Jurgen Klopp's side remained perfect in UCL group play with six wins from six matches, while Milan finished bottom of the Group B table, with Porto finishing third and headed to the Europa League.
It was also the first time in Liverpool's history that they had chalked up a sixth consecutive victory in the competition.
"What the boys did tonight, I could not be more proud," Klopp said. "The performance was outstanding. Having 21 shots, so many situations where we played outstandingly well and defended passionately and well organised."
With top spot wrapped up before kickoff, Liverpool made eight changes, handing Origi a rare start after his heroics against Wolves.
"We chose that lineup because we wanted to win the game. We needed fresh legs," Klopp explained. "We needed desire to play this game which is difficult in this hectic schedule to always be on fire for the next game."
San Siro erupted after Takumi Minamino missed a clearance from a corner in the 29th minute, forcing Alisson to parry the ball into Tomori's path for a simple finish.
But just as the home crowd started to believe in an improbable final-day climb into the top two, Salah struck.
Oxlade-Chamberlain's shot was beaten away by goalkeeper Mike Maignan, but the Egyptian reacted quickly to fire home.
Salah became the first Liverpool player to score 20 or more goals in five consecutive seasons since Ian Rush, who did so for six campaigns in a row between 1981 and 1987.
Tomori was then punished when he gave the ball away to Sadio Mane after the break and although the winger's shot was well blocked by Maignan, Origi headed in the rebound.
The Rossoneri played with more purpose in the second half but could not find an equaliser, Franck Kessie squandering their best chance when he was denied one-on-one by Alisson.
"We wanted to give a joy to our fans but we didn't manage it," disappointed Milan coach Stefano Pioli said. "We have learnt a lot in these six matches."
Information from Reuters was used in this report.