The geochemistry of uranium and thorium is of considerable importance for understanding the Earth's heat budget, for U–Th–Pb age determinations, for the origin of ore deposits, and because disequilibria between the radioactive daughters of ^(238)U and ^(232)Th provide constraints on processes occurring during the generation of magmas. We have studied experimentally the partitioning of uranium and thorium between a haplogranitic melt and aqueous fluids containing variable amounts of HCl, HF and CO_2, at 2 kbar, 750 °C and the oxygen fugacity of the Ni–NiO buffer. The partition coefficients K^(fluid/melt)_D are very low for both uranium and thorium if water is the only volatile component present, but they increase strongly with increasing fluoride concentration, indicating the formation of fluoride complexes in the fluid. Chloride and CO_2, on the other hand, form complexes with uranium, but not with thorium. These results explain the origin of hydrothermal uranium and thorium deposits, the fractionation of uranium from thorium during magma formation, and the depletion of uranium relative to thorium in granulite-facies rocks.