Mario Pasalic gave Atalanta the lead in the 15th minute from close range with a low cross from Davide Zappacosta and United, who have won one in their last five games in all competitions, looked lost in confidence.
It was not surprising that the Italian team doubled their lead in the 29th minute after Merih Demiral rose at the near post to header into the net after a corner kick by Ton Copmaners.
Fred and Marcus Rashford missed good chances for United before the break, but the home team returned to the atmosphere of the match in the 53rd minute.
Bruno Fernandes passed a smart ball to Rashford, who ran into the center of the field from the left and fired into the far corner.
United equalized when Harry Maguire put the ball into the net at the far post after the Atalanta defense failed to clear a ball from Fernandes inside the penalty area.
The winning goal came when Luke Shaw sent a superb cross pass from the left and Ronaldo rose in an amazing way to head perfectly past goalkeeper Juan Musso.
United leads the group after three matches with six points, while Atalanta and Villarreal are two points behind.