AbstractAimSecondary forests regenerating from human disturbance are increasingly becoming a predominant forest type in many regions, and they play a significant role in forest community dynamics. Understanding the factors that underlie the variation in species responses during secondary succession is important for understanding community assembly and biodiversity monitoring and management. Because species vary in ecology and behaviour, responses to ecosystem change should vary among species. Here, we show that habitat type (riparian, upland), phylogeny, and species traits mediate anuran and lizard probability of occurrence and species richness in pasture and secondary forest.LocationSarapiquí and Osa Peninsula, Costa Rica.MethodsWe used phylogenetic occupancy models to estimate assemblage‐level and species‐specific responses to forest succession in 30 chronosequence sites that include pasture, secondary forest regenerating from pasture, and mature forest sites.ResultsFor the majority of species, we found increasing probability of occurrence in upland habitats as forest regenerated from pasture to secondary forest and similar probability of occurrence in riparian habitats across pasture, secondary forest, and mature forest sites. Species' responses to forest stage were phylogenetically correlated, and the trend was especially strong for anuran response to pasture sites. Anurans with lentic larval habitat had a positive occupancy response to pasture upland habitat, and anurans with lotic larval habitat had a variable response to different forest stages compared to mature forest.Main ConclusionsOur study, which focuses on sites that are minimally isolated from mature forest reference sites, indicated that anuran and lizard occupancy rapidly recovered to a level similar to mature forest in a relatively short time span (approximately 20 years). Riparian habitats are key ecosystem features in our system and provide refugia for organisms in early successional stages. Maintenance of vegetation along streams shows that we can mitigate forest conversion by maintaining riparian buffers.