The spin of a planet arises from the accretion of angular momentum during its formation, but the details of this process are still unclear. In the Solar System, the equatorial rotation velocities and, consequently, spin angular momenta of most of the planets increase with planetary mass; the exceptions to this trend are Mercury and Venus, which, since formation, have significantly spun down because of tidal interactions. Here we report near-infrared spectroscopic observations, at a resolving power of 100,000, of the young extrasolar gas giant planet β Pictoris b (refs 7, 8). The absorption signal from carbon monoxide in the planet's thermal spectrum is found to be blueshifted with respect to that from the parent star by approximately 15 kilometres per second, consistent with a circular orbit. The combined line profile exhibits a rotational broadening of about 25 kilometres per second, meaning that β Pictoris b spins significantly faster than any planet in the Solar System, in line with the extrapolation of the known trend in spin velocity with planet mass.