The majority of ultraluminous X-ray sources are point sources that are spatially offset from the nuclei of nearby galaxies and whose X-ray luminosities exceed the theoretical maximum for spherical infall (the Eddington limit) onto stellar-mass black holes(1,2). Their X-ray luminosities in the 0.5-10 kiloelectronvolt energy band range from 10(39) to 10(41) ergs per second(3). Because higher masses imply less extreme ratios of the luminosity to the isotropic Eddington limit, theoretical models have focused on black hole rather than neutron star systems(1,2). The most challenging sources to explain are those at the luminous end of the range (more than 10(40) ergs per second), which require black hole masses of 50-100 times the solar value or significant departures from the standard thin disk accretion that powers bright Galactic X-ray binaries, or both. Here we report broadband X-ray observations of the nuclear region of the galaxy M82 that reveal pulsations with an average period of 1.37 seconds and a 2.5-day sinusoidal modulation. The pulsations result from the rotation of a magnetized neutron star, and the modulation arises from its binary orbit. The pulsed flux alone corresponds to an X-ray luminosity in the 3-30 kiloelectronvolt range of 4.9 x 10(39) ergs per second. The pulsating source is spatially coincident with a variable source(4) that can reach an X-ray luminosity in the 0.3-10 kiloelectronvolt range of 1.8 x 10(40) ergs per second(1). This association implies a luminosity of about 100 times the Eddington limit for a 1.4-solar-mass object, or more than ten times brighter than any known accreting pulsar. This implies that neutron stars may not be rare in the ultraluminous X-ray population, and it challenges physical models for the accretion of matter onto magnetized compact objects.