Electron cyclotron resonance plasma-assisted molecular-beam epitaxy has been used to grow hexagonal and cubic GaN crystal layers on Si(100). By a combined application of in-situ reflection high-energy electron diffraction, X-ray photoelectron spectroscopy and cross-sectional transmission electron microscopy, the state of the Si(001) surface, the structure of GaN grown on this surface and the orientation relationship between substrate and layer were determined. Substrate cleaning, surface reconstruction and carbon surface contamination were found to have a strong effect on GaN growth in the early stage of epitaxy (up to 2000 Angstrom). While polycrystalline GaN in its hexagonal phase is obtained on a clean Si(001) surface, cubic GaN grows epitaxially on a Si(001)c(4 x 4) surface covered by small three-dimensional cubic beta-SiC crystallites.