The magnetic flux rope is among the most fundamental magnetic configurations in plasma. Although its presence after solar eruptions has been verified by spacecraft measurements near Earth, its formation on the Sun remains elusive, yet is critical to understanding a broad spectrum of phenomena. Here we study the dynamic formation of a magnetic flux rope during a classic two-ribbon flare. Its feet are identified unambiguously with conjugate coronal dimmings completely enclosed by irregular bright rings, which originate and expand outward from the far ends of flare ribbons. The expansion is associated with the rapid ribbon separation during the flare main phase. Counting magnetic flux through the feet and the ribbon-swept area reveals that the rope’s core is more twisted than its average of four turns. It propagates to the Earth as a typical magnetic cloud possessing a similar twist profile obtained by the Grad-Shafranov reconstruction of its three dimensional structure.