We analyze the physical mechanisms that form a three-dimensional coronal flux rope and later cause its eruption. This is achieved by a zero-β magnetohydrodynamic (MHD) simulation of an initially potential, asymmetric bipolar field, which evolves by means of simultaneous slow magnetic field diffusion and sub-Alfvenic, line-tied shearing motions in the photosphere. As in similar models, flux-cancellation-driven photospheric reconnection in a bald-patch (BP) separatrix transforms the sheared arcades into a slowly rising and stable flux rope. A bifurcation from a BP to a quasi-separatrix layer (QSL) topology occurs later on in the evolution, while the flux rope keeps growing and slowly rising, now due to shear-driven coronal slip-running reconnection, which is of tether-cutting type and takes place in the QSL. As the flux rope reaches the altitude at which the decay index –∂ln B/∂ln z of the potential field exceeds ~3/2, it rapidly accelerates upward, while the overlying arcade eventually develops an inverse tear-drop shape, as observed in coronal mass ejections (CMEs). This transition to eruption is in accordance with the onset criterion of the torus instability. Thus, we find that photospheric flux-cancellation and tether-cutting coronal reconnection do not trigger CMEs in bipolar magnetic fields, but are key pre-eruptive mechanisms for flux ropes to build up and to rise to the critical height above the photosphere at which the torus instability causes the eruption. In order to interpret recent Hinode X-Ray Telescope observations of an erupting sigmoid, we produce simplified synthetic soft X-ray images from the distribution of the electric currents in the simulation. We find that a bright sigmoidal envelope is formed by pairs of -shaped field lines in the pre-eruptive stage. These field lines form through the BP reconnection and merge later on into -shaped loops through the tether-cutting reconnection. During the eruption, the central part of the sigmoid brightens due to the formation of a vertical current layer in the wake of the erupting flux rope. Slip-running reconnection in this layer yields the formation of flare loops. A rapid decrease of currents due to field line expansion, together with the increase of narrow currents in the reconnecting QSL, yields the sigmoid hooks to thin in the early stages of the eruption. Finally, a slightly rotating erupting loop-like feature (ELLF) detaches from the center of the sigmoid. Most of this ELLF is not associated with the erupting flux rope, but with a current shell that develops within expanding field lines above the rope. Only the short, curved end of the ELLF corresponds to a part of the flux rope. We argue that the features found in the simulation are generic for the formation and eruption of soft X-ray sigmoids.