The opening of the Gibraltar land bridge occurred at the end of the Messinian Salinity Crisis approximately 5.3 Mya, and was one of the main causes of vicariance between European and north-west African amphibians, resulting in the origin of several new species. However, little is currently known about the causes for post-Messinian amphibian differentiation in the Maghreb, although it is acknowledged that the Pleistocene glaciations probably had considerable influence on several species. The current study uses both species distribution modelling (MAXENT) and information from a total of 694 bp of mitochondrial data (351 from cytochrome b and 342 from 12S rRNA) from 36 representatives of all three recognized subspecies of Moroccan Salamandra to infer the phylogeny and biogeography of Salamandra algira tingitana, which is characterized by both viviparous and ovoviviparous populations. According to the results, the split between S. a. tingitana and S. a. algira from the Rif and Middle Atlas mountains took place approximately 1.6 Mya, and could have been caused by a shift towards a colder and drier climate that occurred during the upper Pliocene, which may have resulted in the isolation of Salamandra at increasingly higher altitudes, or in other climatically favourable areas. Several lineages within S. a. tingitana originated during the Pleistocene climatic oscillations, one of which gave rise to the viviparous populations north of the Oued Martil. It is suggested that the origin of viviparity in S. a. tingitana occurred during the last 600 000 years. In order to further understand the origin of the unique viviparous population of S. algira from North Africa, predictive distribution models of the viviparous and ovoviviparous populations of S. a. tingitana were created using MAXENT to assess environmental differences. Niche divergence was subsequently determined using Schoener's D and Warren et al.'s I niche similarity metrics. Predictive modelling and niche divergence analyses revealed significant environmental differences between the two reproductive types, which could have influenced the transition from ovoviviparity to viviparity. © 2010 The Linnean Society of London, Biological Journal of the Linnean Society, 2010, 101, 626–641.