The preference of XeF6 for either a trigonally distorted or a regular octahedral structure is determined by a delicate balance of several competing factors. A regular octahedron is favored (a) by electron correlation and (b) by the relativistic contraction of the Xe 5s orbital. In contrast, higher angular momentum (in particular f-type) basis functions on Xe favor a distortion. While earlier SCF or other nonrelativistic calculations were in apparent agreement with experimental evidence for a distorted structure, this has been due to a partial cancellation of errors. The present study contains all-electron calculations as well as calculations of the valence-electrons in an effective core potential. For the former, electron correlation has been included at the MP2 level and relativistic effects by means of direct perturbation theory, for the latter the highest level was CCSD(T) for the treatment of electron correlation, and relativistic effects were simulated by means of a quasirelativistic effective core p...