Juve, missing Cristiano Ronaldo due to injury, struggled to break down the in-form hosts without their Portuguese talisman and were forced to defend for much of the second half against Serie A's top scorers.
It looked as though Juve had done enough to hold on for a point, but substitute Ruslan Malinovskiy snatched a fifth successive league win for Atalanta in the 87th minute, sparking wild scenes of celebration.
Atalanta moved on to 64 points, two ahead of Juventus, from 31 games played after a first league win over Juve for more than 20 years.
Juve's hopes of a 10th successive Scudetto are now all but over as they trail leaders Inter Milan, who play Napoli later on Sunday, by 12 points. Victory for Napoli would move them level on points with Andrea Pirlo's side.
Sixth-placed Lazio moved four points behind Juventus, having played one game less, after an entertaining 5-3 win over Benevento -- their fifth league victory in a row -- while Bologna beat Spezia 4-1.
In-form Atalanta took the game to Juve early on in Bergamo, with Matteo Pessina wasting a glorious chance to give the hosts the lead.
Atalanta have conceded the most goals of any of the top six and hesitation in his own penalty area from Joakim Maehle gave Alvaro Morata a great chance to break the deadlock. However, the Spaniard's tame effort was cleared off the line late in the opening period.
Paulo Dybala, starting for the first time since early January, tired as the match wore on and had to be replaced, leaving Juve short of options up front.
As a result, Pirlo's side sat back, happy to take the point, but moments after Malinovskiy's stunning freekick was brilliantly saved by Wojciech Szczesny, he popped up with the winner, his strike taking a huge deflection en route to goal