Emanuele Giaccherini scored eight minutes from the final whistle to earn Bologna a 1-0 win from their trip to San Siro and ensure that AC Milan got off to a losing start after Serie A's winter break.
The Rossoneri were unbeaten in their previous six outings in all competitions, but the defeat in front of their own supporters has seen them lose ground in the title race.
Chances were at a premium for much of the contest, which appeared to be ending in a goalless draw until former Sunderland and Juventus midfielder Giaccherini struck.
Anthony Mounier floated a cross over to the back post for the unmarked Italian, who took one touch before sending his shot beyond the reach of advancing Milan goalkeeper Gianluigi Donnarumma.
Milan, who are now 10 points adrift of leaders Fiorentina, were unable to mount a comeback as 15th-placed Bologna held out to claim the victory.