The Brazilian notched his 100th and 101st goal for the club, while Bryan Cristante opened his account in a comprehensive Rossoneri victory
The Brazil international became the 10th Milan player to reach a century of goals for the club when he found the net with a composed finish 10 minutes before the break.
Milan were relieved to see Atalanta's Yohan Benalouane, who started instead of Cristiano Del Grosso, have a goal disallowed for a push shortly after half-time - and they duly took full advantage.
Kaka, wearing the captain's armband in the absence of injured skipper Riccardo Montolivo, netted his 101st goal for Milan in the 65th minute with a close-range finish, and teenager Bryan Cristante then capped his first league start with the third two minutes later.
Victory, which is only Milan's fifth in Serie A this season, sees them move onto 22 points, four clear of Atalanta.
Allegri made six changes to the side beaten by rivals Inter before the mid-season break, including Alessandro Matri coming in for Mario Balotelli - who was deemed fit enough only for the bench due to flu - and 18-year-old Cristante starting in place of the suspended Sulley Muntari.
Milan started brightly and created a great chance for Cristante in the opening stages, but his first-time effort crashed against the bar with Andrea Consigli well beaten.
The visiting goalkeeper was left with no chance again in the 35th minute - and this time, the woodwork did not save him as Milan took the lead courtesy of Kaka’s milestone goal.
Urby Emanuelson broke out of defence before playing the Brazilian in behind the Atalanta defence, and the 31-year-old calmly slid the ball beyond Consigli.
The visitors started the second half positively and thought they had levelled in 52nd minute through Benalouane, but the midfielder was adjudged to have fouled Philippe Mexes in the build-up.
Christian Abbiati had to be alert again three minutes later as he made a fantastic reaction save with his legs to deny German Denis after a Maximiliano Moralez cross.
After withstanding intense pressure from Atalanta, Milan doubled their lead just after the hour as Kaka grabbed his second of the game.
Balotelli, on in place of Matri, fired a cross in from the right, and the ball fell perfectly for the former Real Madrid man after striking Robinho, and he swept home from four yards.
Cristante added the third with his first Milan goal soon after, as the youngster fired low across Consigli into the bottom corner from 20 yards.
Allegri's side pushed for further goals, but although Balotelli and Kaka went close, they were unable to find a fourth.