Duvan Zapata scored one and set up the other just as the match seemed to be heading for extra time.
Atalanta will need to be more clinical with its finishing against Juventus, which has won the competition a record 13 times, including each of the past four seasons when it has won the league and cup double.
In Sardinia, the visitors had several chances and also hit the woodwork three times.
They eventually broke through two minutes from time with a close-range header from Zapata, and the Colombia forward helped make sure of the result in stoppage time when he set up Mario Pasalic, who had only just come off the bench.
ONLY TOP FLIGHT TEAMS
Patrik Schick scored two and set up another as Roma eliminated the only lower-division team left in the Italian Cup.
Roma crushed third-division Virtus Entella 4-0 to book a quarterfinal tie against Fiorentina.
Entella eliminated Serie A side Genoa in the previous round but it appeared as if it was set for a mauling when Schick gave Roma the lead after just 23 seconds with a cool backheel flick.
But the visitors had a goal ruled out for offside and it took Roma until first-half stoppage time to double its lead when substitute Ivan Marcano drove home another flick from Schick.
The Czech Republic forward doubled his tally immediately after the break and Entella had another goal ruled out for offside before Javier Pastore sealed the result 15 minutes from time.
Source: Fox Sports