BNSF Railway Co., one of the biggest U.S. consumers of diesel fuel, plans this year to test using natural gas to power its locomotives instead.

If successful, the experiment could weaken oil's dominance as a transportation fuel and provide a new outlet for the glut of cheap natural gas in North America.

The surplus, spurred by new technologies...