A star like the Sun becomes a planetary nebula towards the end of its life, when the envelope ejected during the earlier giant phase becomes photoionized as the surface of the remnant star reaches a temperature of ~30,000K. The spherical symmetry of the giant phase is lost in the transition to a planetary nebula, when non-spherical shells and powerful jets develop. Molecules that were present in the giant envelope are progressively destroyed by the radiation. The water-vapour masers that are typical of the giant envelopes therefore are not expected to persist in planetary nebulae. Here we report the detection of water-maser emission from the planetary nebula K3-35. The masers are in a magnetized torus with a radius of about 85 astronomical units and are also found at the surprisingly large distance of about 5,000 astronomical units from the star, in the tips of bipolar lobes of gas. The precessing jets from K3-35 are probably involved in the excitation of the distant masers, although their existence is nevertheless puzzling. We infer that K3-35 is being observed at the very moment of its transformation from a giant star to a planetary nebula.