Variable X-ray and gamma-ray emission is characteristic of the most extreme physical processes in the Universe, and studying the sources of these energetic photons has been a major driver in astronomy for the past 50 years. Here we present multiwavelength observations of a unique gamma-ray selected transient, discovered by Swift, which was accompanied by bright emission across the electromagnetic spectrum, and whose properties are unlike any previously observed source. We pinpoint the event to the center of a small, star-forming galaxy at redshift z=0.3534. Its high-energy emission has lasted much longer than any gamma-ray burst, while its peak luminosity was about 100 times higher than the brightest active galactic nuclei. The association of the outburst with the center of its host galaxy suggests that this phenomenon has its origin in a new, rare mechanism associated with a massive black hole in the nucleus of a galaxy.