The interactions between an organism and its environment are mediated by cognition, the substrates of which are in the brain. Cognition is ubiquitous across vertebrates, yet we still know very little about the factors shaping its evolution, particularly outside of birds and mammals. In natural environments, cognition likely impacts organism fitness. Behavioral flexibility, which enables an animal to modulate its behavior to match its environment, may facilitate success in novel habitats, such as in dispersal to islands, biotic invasions, and urban adaptation. Cognitive specializations may also be associated with specific ecological traits, such as habitat complexity. Furthermore, our understanding of the neural substrates of cognition in the brain is primarily limited to studies of relative brain size. The first chapter provides a more in depth introduction to these topics. In this dissertation, I explore the interactions between cognition, neuroanatomy, and ecology in Anolis lizards. Anolis lizards exhibit a diversity of habitat specializations, which is the result of adaptive radiation in the West Indies. As mentioned above, cognitive mechanisms in anoles may play a role in adjusting to novel environments and exploiting new niches. In the second chapter, I modified a detour task to evaluate whether wild, free-living Anolis sagrei can solve a novel detour problem under natural conditions. In the second chapter, I compare the neuron and nonneuron number and density of Anolis cristatellus and Anolis evermanni to see whether differences in neuroanatomy reflect their differential performance on an extractive foraging task. I also explore how these data relate to published observations from other vertebrates. Finally, in the fourth chapter I expand upon two previous studies by evaluating whether neuron number follows the predictions of concerted or mosaic evolution in five species of Puerto Rican Anolis and whether habitat complexity explains differences in neuron density between species. I conclude in the final chapter by summarizing my results and outlining future directions. Taken together, the results presented in this dissertation demonstrate the potential for studying cognition and neuroanatomy in an evolutionary context. The methods applied in my second chapter can be used in the future to explore the connection between cognition and fitness in lizards, which are a tractable model for such studies under natural conditions. My third and fourth chapters took a novel approach by studying neuroanatomical differences between species in neuron number and density, and generated novel insights into brain evolution in Anolis. By studying cognition and the brain in lizards and other ectotherms, we can begin to finally understand factors shaping the evolution of cognition and neuroanatomy across vertebrates.