The abundances of oxygen isotopes in the most refractory mineral phases (calcium-aluminium-rich inclusions, CAIs) in meteorites have hitherto defied explanation. Most processes fractionate isotopes by nuclear mass; that is, 18O is twice as fractionated as 17O, relative to 16O. In CAIs 17O and 18O are nearly equally fractionated, implying a fundamentally different mechanism. The CAI data were originally interpreted as evidence for supernova input of pure 16O into the solar nebula, but the lack of a similar isotope trend in other elements argues against this explanation. A symmetry-dependent fractionation mechanism may have occurred in the inner solar nebula, but experimental evidence is lacking. Isotope-selective photodissociation of CO in the innermost solar nebula might explain the CAI data, but the high temperatures in this region would have rapidly erased the signature. Here we report time-dependent calculations of CO photodissociation in the cooler surface region of a turbulent nebula. If the surface were irradiated by a far-ultraviolet flux approximately 10(3) times that of the local interstellar medium (for example, owing to an O or B star within approximately 1 pc of the protosun), then substantial fractionation of the oxygen isotopes was possible on a timescale of approximately 10(5) years. We predict that similarly irradiated protoplanetary disks will have H2O enriched in 17O and 18O by several tens of per cent relative to CO.