How strong is the natural selection that maintains species and locally adapted populations in the face of gene flow? To what extent is genomic divergence limited by gene flow? Here, we use DNA polymorphism data and the genome-wide variation in recombination rate to infer the strength and timing of selection, and the baseline level of gene flow under various demographic scenarios. To achieve this, we develop theory that merges the coalescent process with the concept of effective gene flow. The latter describes the reduction in gene flow at neutral loci due to divergent selection against maladapted immigrant alleles. This effect decreases with recombinational distance from the loci under selection, such that in regions of low recombination genetic divergence among populations is on average increased compared to regions of high recombination. Our inference procedure exploits this relationship in a genome-wide aggregate manner. We validate our approach using individual-based simulations and apply it to two datasets from the yellow monkeyflower (Mimulus guttatus). First, we infer a strong signal of adaptive divergence in the face of gene flow between populations growing on and off phytotoxic serpentine soils. We show that the genome-wide intensity of this selection is not exceptional compared to what M. guttatus may usually experience when adapting to local conditions. Second, we quantify and date selection against introgression from the selfing sister species M. nasutus. Our study provides a theoretical framework that explicitly links genome-wide patterns of divergence and recombination with the underlying evolutionary mechanisms.