Millisecond pulsars are thought to be neutron stars that have been spun-up by accretion of matter from a binary companion. Although most are in binary systems, some 30% are solitary, and their origin is therefore mysterious. PSR J1719-1438, a 5.7-millisecond pulsar, was detected in a recent survey with the Parkes 64-meter radio telescope. We show that this pulsar is in a binary system with an orbital period of 2.2 hours. The mass of its companion is near that of Jupiter, but its minimum density of 23 grams per cubic centimeter suggests that it may be an ultralow-mass carbon white dwarf. This system may thus have once been an ultracompact low-mass x-ray binary, where the companion narrowly avoided complete destruction.