The clustering of dark haloes depends not only on their mass but also on their assembly history, a dependence we term 'assembly bias'. Using a galaxy formation model grafted on to the Millennium Simulation of the ACDM cosmogony, we study how assembly bias affects galaxy clustering. We compare the original simulation to 'shuffled' versions where the galaxy populations are randomly swapped among haloes of similar mass, thus isolating the effects of correlations between assembly history and environment at fixed mass. Such correlations are ignored in the halo occupation distribution models often used populate dark matter simulations with galaxies, but they are significant in our more realistic simulation. Assembly bias enhances two-point correlations by 10 per cent for galaxies with MbJ - 5 log h brighter than -17, but suppresses them by a similar amount for galaxies brighter than -20. When such samples are split by colour, assembly bias is 5 per cent stronger for red galaxies and 5 per cent weaker for blue ones. Halo central galaxies are differently affected by assembly bias than are galaxies of all types. It almost doubles the correlation amplitude for faint red central galaxies. Shuffling galaxies among haloes of fixed formation redshift or concentration in addition to fixed mass produces biases which are not much smaller than when mass alone is fixed. Assembly bias must reflect a correlation of environment with aspects of halo assembly which are not encoded in either of these parameters. It induces effects which could compromise precision measurements of cosmological parameters from large galaxy surveys.