Introduction: Walking in complex environments increases the cognitive demand of locomotor control; however, our understanding of the neural mechanisms contributing to walking on uneven terrain is limited. We used a novel method for altering terrain unevenness on a treadmill to investigate the association between terrain unevenness and cortical activity in the prefrontal cortex, a region known to be involved in various cognitive functions. Methods: Prefrontal cortical activity was measured with functional near infrared spectroscopy while participants walked on a novel custom-made terrain treadmill surface across four different terrains: flat, low, medium, and high levels of unevenness. The assessments were conducted in younger adults, older adults with better mobility function and older adults with worse mobility function. Mobility function was assessed using the Short Physical Performance Battery. The primary hypothesis was that increasing the unevenness of the terrain would result in greater prefrontal cortical activation in all groups. Secondary hypotheses were that heightened prefrontal cortical activation would be observed in the older groups relative to the younger group, and that prefrontal cortical activation would plateau at higher levels of terrain unevenness for the older adults with worse mobility function, as predicted by the Compensation Related Utilization of Neural Circuits Hypothesis. Results: The results revealed a significant main effect of terrain, indicating a significant increase in prefrontal cortical activation with increasing terrain unevenness during walking in all groups. A significant main effect of group revealed that prefrontal cortical activation was higher in older adults with better mobility function compared to younger adults and older adults with worse mobility function in all pooled terrains, but there was no significant difference in prefrontal cortical activation between older adults with worse mobility function and younger adults. Contrary to our hypothesis, the older group with better mobility function displayed a sustained increase in activation but the other groups did not, suggestive of neural compensation. Additional findings were that task-related increases in prefrontal cortical activation during walking were lateralized to the right hemisphere in older adults with better mobility function but were bilateral in older adults with worse mobility function and younger adults. Discussion: These findings support that compared to walking on a flat surface, walking on uneven terrain surfaces increases demand on cognitive control resources as measured by prefrontal cortical activation.