We present a study of galaxy environments to z similar to 2, based on a sample of over 33 000 K-band-selected galaxies detected in the UKIDSS Ultra Deep Survey (UDS). The combination of infrared depth and area in the UDS allows us to extend previous studies of galaxy environment to z > 1 without the strong biases associated with optical galaxy selection. We study the environments of galaxies divided by rest-frame (U - B) colours, in addition to 'passive' and 'star-forming' subsets based on template fitting. We find that galaxy colour is strongly correlated with galaxy overdensity on small scales (< 1-Mpc diameter), with red/passive galaxies residing in significantly denser environments than blue/star-forming galaxies to z similar to 1.5. On smaller scales (< 0.5-Mpc diameter) we also find a relationship between galaxy luminosity and environment, with the most luminous blue galaxies at z similar to 1 inhabiting environments comparable to red, passive systems at the same redshift. Monte Carlo simulations demonstrate that these conclusions are robust to the uncertainties introduced by photometric redshift errors.