Mayr's best recognized scientific contributions include the biological species concept and the theory of geographic speciation. In the latter, reproductive isolation evolves as an incidental by-product of genetic divergence between allopatric populations. Mayr noted that divergent natural selection could accelerate speciation, but also argued that gene flow so strongly retards divergence that, even with selection, non-allopatric speciation is unlikely. However, current theory and data demonstrate that substantial divergence, and even speciation, in the face of gene flow is possible. Here, I attempt to connect some opposing views about speciation by integrating Mayr's ideas about the roles of ecology and geography in speciation with current data and theory. My central premise is that the speciation process (i.e. divergence) is often continuous, and that the opposing processes of selection and gene flow interact to determine the degree of divergence (i.e. the degree of progress towards the completion of speciation). I first establish that, in the absence of gene flow, divergent selection often promotes speciation. I then discuss how population differentiation in the face of gene flow is common when divergent selection occurs. However, such population differentiation does not always lead to the evolution of discontinuities, strong reproductive isolation, and thus speciation per se. I therefore explore the genetic and ecological circumstances that facilitate speciation in the face of gene flow. For example, particular genetic architectures or ecological niches may tip the balance between selection and gene flow strongly in favour of selection. The circumstances allowing selection to overcome gene flow to the extent that a discontinuity develops, and how often these circumstances occur, are major remaining questions in speciation research. © 2008 The Linnean Society of London, Biological Journal of the Linnean Society, 2008, 95, 26–46.