Populations at the margins of a species' geographic range are often thought to be poorly adapted to their environment. According to theoretical predictions, gene flow can inhibit these range edge populations if it disrupts adaptation to local conditions. Alternatively, if range edge populations are small or isolated, gene flow can provide beneficial genetic variation, and may facilitate adaptation to environmental change. We tested these competing predictions in the annual wildflower Clarkia pulchella using greenhouse crosses to simulate gene flow from sources across the geographic range into two populations at the northern range margin. We planted these between-population hybrids in common gardens at the range edge, and evaluated how genetic differentiation and climatic differences between edge populations and gene flow sources affected lifetime fitness. During an anomalously warm study year, gene flow from populations occupying historically warm sites improved fitness at the range edge, and plants with one or both parents from warm populations performed best. The effects of the temperature provenance of gene flow sources were most apparent at early life history stages, but precipitation provenance also affected reproduction. We also found benefits of gene flow that were independent of climate: after climate was controlled for, plants with parents from different populations performed better at later lifestages than those with parents from the same population, indicating that gene flow may improve fitness via relieving homozygosity. Further supporting this result, we found that increasing genetic differentiation of parental populations had positive effects on fitness of hybrid seeds. Gene flow from warmer populations, when it occurs, is likely to contribute adaptive genetic variation to populations at the northern range edge as the climate warms. On heterogeneous landscapes, climate of origin may be a better predictor of gene flow effects than geographic proximity