In the final phase of their spawning migration, Pacific salmon use chemical cues to identify their home river, but how they navigate from the open ocean to the correct coastal area has remained enigmatic. To test the hypothesis that salmon imprint on the magnetic field that exists where they first enter the sea and later seek the same field upon return, we analyzed a 56-year fisheries data set on Fraser River sockeye salmon, which must detour around Vancouver Island to approach the river through either a northern or southern passageway. We found that the proportion of salmon using each route was predicted by geomagnetic field drift: the more the field at a passage entrance diverged from the field at the river mouth, the fewer fish used the passage. We also found that more fish used the northern passage in years with warmer sea surface temperature (presumably because fish were constrained to more northern latitudes). Field drift accounted for 16% of the variation in migratory route used, temperature 22%, and the interaction between these variables 28%. These results provide the first empirical evidence of geomagnetic imprinting in any species and imply that forecasting salmon movements is possible using geomagnetic models.