The ecological cognition hypothesis poses that the brains and behaviours of individuals are largely shaped by the environments in which they live and the associated challenges they must overcome during their lives. Here we examine the effect of environmental complexity on relative brain size in 4 species of intertidal gobies from differing habitats. Two species were rock pool specialists that lived on spatially complex rocky shores, while the remainder lived on dynamic, but structurally simple, sandy shores. We found that rock pool-dwelling species had relatively larger brains and telencephalons in particular, while sand-dwelling species had a larger optic tectum and hypothalamus. In general, it appears that various fish species trade off neural investment in specific brain lobes depending on the environment in which they live. Our previous research suggests that rock pool species have greater spatial learning abilities, enabling them to navigate their spatially complex environment, which may account for their enlarged telencephalon, while sand-dwelling species likely have a reduced need for spatial learning, due to their spatially simple habitat, and a greater need for visual acuity. The dorsal medulla and cerebellum size was unaffected by the habitat in which the fish lived, but there were differences between species indicative of species-specific trade-offs in neural investment.