Social structure is a fundamental component of a population that drives ecological and evolutionary processes ranging from parasite transmission to sexual selection. Nevertheless, we have much to learn about factors that explain variation in social structure. We used advances in biologging and social network analysis to experimentally test how the local habitat, and specifically habitat complexity, modulates social structure at different levels in wild populations. Sleepy lizards, Tiliqua rugosa, establish nonrandom social networks that are characterized by avoidance of some neighbours and frequent interactions with one opposite-sex individual. Using synchronous GPS locations of all adult lizards, we constructed social networks based on spatial proximity of individuals. We increased habitat structural complexity in two study populations by adding 100 short fences across the landscape. We then compared the resulting movement behaviour and social structure between these populations and two unmanipulated populations. Social connectivity (network density) and social stability, measured at weekly intervals, were greater in populations with increased habitat structural complexity. The level of agonistic interaction (quantified as scale damage) was also higher, indicating a fitness cost of greater social connectivity. However, some network parameters were unaffected by increased complexity, including disassortative mixing by sex, and at the individual level, social differentiation among associates (coefficient of variation of edge weights) and maximal interaction frequencies (maximal edge weight). This suggests divergent effects of changed ecological conditions on individual association behaviour compared to the resulting social structure of the population. Our results contrast with those from studies of more gregarious species, in which higher structural complexity in the environment relaxed the social connectivity. This shows that the response to altered ecological conditions can differ fundamentally between species or between populations, and we suggest that it depends on their tendency for gregarious behaviour.