Goals from Alejandro Gomez and Mauricio Pinilla saw Atalanta record a 2-1 Serie A win over AC Milan at the Stadio Atleti Azzurri d'Italia on Sunday.
Luiz Adriano had earned Milan an early lead when he converted a penalty, but Pinilla restored parity shortly before the interval with a fantastic bicycle kick.
Gomez then delivered the hosts all three points with a cool finish at the hour mark as they moved further away from the drop zone.
Milan, meanwhile, are only one point clear of Sassuolo in the battle for sixth place following this weekend's results as they chase Europa League football.
The game started with a minute's silence before kick-off in memory of Milan great Cesare Maldini, who passed away at the age of 84.
Milan started the match in brilliant fashion and needed only five minutes to open the scoring. Referee Gianluca Rocchi had no other option but to point to the spot after Guglielmo Stendardo handled the ball inside his own area and Luiz Adriano coolly converted from 12 yards.
Atalanta nearly replied immediately when Pinilla reached Gomez with a fine cross from the right, but Ignazio Abate did well to deflect the Argentine's header wide for a corner.
Mattia De Sciglio was next to threaten for Milan after a quick counterattack, blasting a shot wide from a narrow angle after some good work from Luiz Adriano in the build-up.
Giacomo Bonaventura fired a shot well over the crossbar halfway through the first half as he seemed desperate to impress against his former club, with Andrea Bertolacci also aiming too high shortly after.
Gomez came close to levelling the scoring shortly before the break, only to be denied by a last-ditch block from Luca Antonelli.
Pinilla did restore parity in the 44th minute, though, and the Chilean did so in spectacular fashion. The Milan defence failed to clear a corner from the right and Pinilla beat shot-stopper Gianluigi Donnarumma with a stunning bicycle kick in the top corner.
Milan struggled to create any chances of note early in the second half as they looked to restore their lead, prompting Sinisa Mihajlovic to bring on Mario Balotelli for Luiz Adriano.
The Liverpool loanee's introduction did not pay off, however, as Atalanta grabbed the lead instead.
Marten de Roon set up Gomez with a clever ball inside the area and the 28-year-old had no trouble finding the net from close range for his seventh league goal of the season.
Atalanta goalkeeper Marco Sportiello was alert when substitute Jeremy Menez tried his luck with a left-footed shot from inside the area.
Sportiello was again called into action when Balotelli beat the wall with a well-taken free-kick in the 75th minute, punching the ball wide for a corner as the home side held on to a surprise win.
Get the best features, fun and footballing frolics straight to your inbox every week.