Some active asteroids have been proposed to be formed as a result of impact events1. Because active asteroids are generally discovered by chance only after their tails have fully formed, the process of how impact ejecta evolve into a tail has, to our knowledge, not been directly observed. The Double Asteroid Redirection Test (DART) mission of NASA2, in addition to having successfully changed the orbital period of Dimorphos3, demonstrated the activation process of an asteroid resulting from an impact under precisely known conditions. Here we report the observations of the DART impact ejecta with the Hubble Space Telescope from impact time T + 15 min to T + 18.5 days at spatial resolutions of around 2.1 km per pixel. Our observations reveal the complex evolution of the ejecta, which are first dominated by the gravitational interaction between the Didymos binary system and the ejected dust and subsequently by solar radiation pressure. The lowest-speed ejecta dispersed through a sustained tail that had a consistent morphology with previously observed asteroid tails thought to be produced by an impact4,5. The evolution of the ejecta after the controlled impact experiment of DART thus provides a framework for understanding the fundamental mechanisms that act on asteroids disrupted by a natural impact1,6.