Supermassive black holes have powerful gravitational fields with strong gradients that can destroy stars that get too close, producing a bright flare in ultraviolet and X-ray spectral regions from stellar debris that forms an accretion disk around the black hole. The aftermath of this process may have been seen several times over the past two decades in the form of sparsely sampled, slowly fading emission from distant galaxies, but the onset of the stellar disruption event has not hitherto been observed. Here we report observations of a bright X-ray flare from the extragalactic transient Swift J164449.3+573451. This source increased in brightness in the X-ray band by a factor of at least 10,000 since 1990 and by a factor of at least 100 since early 2010. We conclude that we have captured the onset of relativistic jet activity from a supermassive black hole. A companion paper comes to similar conclusions on the basis of radio observations. This event is probably due to the tidal disruption of a star falling into a supermassive black hole, but the detailed behaviour differs from current theoretical models of such events.