A newborn star is encircled by a remnant disc of gas and dust. A fraction of the disc coalesces into planets. Another fraction spirals inward and accretes onto the star(1). Accreting gas not only produces observed ultraviolet radiation, but also drags along embedded planets, helping to explain otherwise mysterious features of observed extrasolar systems. What drives disc accretion has remained uncertain. The magneto-rotational instability (MRI), driven by coupling between magnetic fields and disc rotation, supplies a powerful means of transport(2), but protoplanetary disc gas might be too poorly ionized to couple to magnetic fields(1-6). Here we show that the MRI explains the observed accretion rates of newly discovered transitional discs(7,8,) which are swept clean of dust inside rim radii of similar to 10 AU. Stellar coronal X-rays ionize the disc rim, activating the MRI there. Gas flows steadily from the rim to the star, at a rate set by the depth to which X-rays ionize the rim wall. Blown out by radiation pressure, dust largely fails to accrete with gas. Our picture supplies one concrete setting for theories of how planets grow and have their orbits shaped by disc gas(9), and when combined with photo-evaporative disc winds(10) provides a framework for understanding how discs dissipate.