Geographic isolation that drives speciation is often assumed to slowly increase over time, for instance through the formation of rivers, the formation of mountains or the movement of tectonic plates. Cyclic changes in connectivity between areas may occur with the advancement and retraction of glaciers, with water level fluctuations in seas between islands or in lakes that have an uneven bathymetry. These habitat dynamics may act as a driver of allopatric speciation and propel local diversity. Here we present a parsimonious model of the interaction between cyclical (but not necessarily periodic) changes in the environment and speciation, and provide an ABC-SMC method to infer the rates of allopatric and sympatric speciation from a phylogenetic tree. We apply our approach to the posterior sample of an updated phylogeny of the Lamprologini, a tribe of cichlid fish from Lake Tanganyika where such cyclic changes in water level have occurred. We find that water level changes play a crucial role in driving diversity in Lake Tanganyika. We note that if we apply our analysis to the Most Credible Consensus tree, we do not find evidence for water level changes influencing diversity in the Lamprologini, suggesting that the MCC tree is a misleading representation of the true species tree. Furthermore, we note that the signature of habitat dynamics is found in the posterior sample despite the fact that this sample was constructed using a species tree prior that ignores habitat dynamics. However, in other cases this species tree prior might erase this signature. Hence we argue that in order to improve inference of the effect of habitat dynamics on biodiversity, phylogenetic reconstruction methods should include tree priors that explicitly take into account such dynamics.