Before some cutting-edge online retailer can use a drone to drop granola bars on your doorstep, a railroad born when Abe Lincoln was in Congress will first have to iron out the kinks.

BNSF Railway Co. is flying drones as far as 150 miles along the New Mexico desert to inspect tracks, helping the Federal Aviation Administration develop rules for operating unmanned aircraft beyond the pilot’s line of sight. That’s an essential step for expanding use to such commercial endeavors as deliveries by Amazon.com and other companies.

“We had to invent a lot of what we’re doing from scratch,” said Todd Graetz, head of the drone team at Fort Worth, Texas-based BNSF, which traces its roots back to the Aurora Branch Railroad’s founding in 1849 and is currently controlled by billionaire Warren Buffett. “It sets the stage for a number of other users.”

The “Holy Grail” is flying drones beyond what ground-based operators can see, said John Walker, co-founder of the Padina Group aerospace consulting firm. The potential uses — from track inspections, to spotting criminals on the lam, to organ deliveries for hospitals — will rival what happened a century ago, when airplanes became indispensable tools instead of stunt machines at county fairs, he said.

“It’s been barnstorming,” said Walker, a former FAA program director. “Now we’re getting into what is the commercial market.”

The FAA is eager to expand rules for long-distance drone flights, said Earl Lawrence, the agency’s director of the office of Unmanned Aircraft Systems Integration. The agency missed a congressional mandate to allow full integration of drones into U.S. airspace by last year, citing safety concerns.

Until recently, the FAA had allowed commercial drone flights only under a cumbersome, case-by-case application process. On Monday, the agency began permitting daytime flights within line of sight, no higher than 400 feet, no faster than 100 miles per hour and, generally, not above people. Those interim rules set a framework eventually to allow night flights, operations over populated areas and service beyond line of sight. The agency expects to introduce those rules next year, Lawrence said.

“How do you eat the elephant? One bite at a time,” he said. “We’re taking it in bites. We’re going from the less complex to the more complex.”

The agency has enlisted assistance from BNSF and other companies to tackle the challenges in an airspace crowded with the most private planes in the world.

“The FAA itself can’t really move this forward on its own. It needs industry,” said Joanna Simon, an associate at Morrison & Foerster. The San Francisco-based law firm’s clients include Facebook Inc., which wants to use drones to provide internet service.

BNSF, owned by Buffett’s Berkshire Hathaway, is particularly suited for the task. The railroad operates 32,500 miles of track crisscrossing sparsely populated areas along a well-defined right of way, which eases planning. Communications towers that are part of a safety system for trains can be used to help guide drones.

The railroad also has a compelling business case. The Latitude HQ-40 drone that Graetz supervises has a six-foot wingspan and is equipped with cameras that when paired with special software can potentially detect track anomalies more quickly, possibly preventing derailments. The flights, from just outside of Playas, N.M., lay the groundwork for drone inspections of other fixed infrastructure, such as pipelines and power lines.

“The more we fly, the more imagery we collect, the more we run it through the analytics, the better things get,” Graetz said.

Another company, PrecisionHawk Inc., is working with partners to use satellite data to build three-dimensional maps so drones by themselves can avoid objects such as grain silos and tall trees, says Tyler Collins, the director of business development. PrecisionHawk has developed drones and software to monitor the health of crop fields.

“One of the most exciting things is that the FAA is fully invested in figuring out how to do this,” he said.

Harris Corp., which operates a network that helps the agency monitor manned aircraft, is developing systems that would extend the coverage to below 500 feet for drones, including through use of the cellular telephone network.

“The challenges of moving beyond visual line of sight shouldn’t be underestimated,” said Carl D’Alessandro, president of critical networks at Harris, which is assisting PrecisionHawk.

Companies including Google and Amazon, which has received permission to test flights beyond line of sight in the U.K., have pushed the FAA to move more quickly. Domino’s Pizza Enterprises last week said it teamed up with drone operator Flirtey to deliver a pizza in New Zealand and plans to test the service there later this year.

“We work with regulators and policy makers in many countries and will continue to do so,” Kristen Kish, a spokeswoman for Amazon, said by e-mail. “We look forward to using drones to safely deliver parcels in 30 minutes to customers around the world.”

The risks of flying autonomous planes long distance are substantial. The drones must be able to detect other aircraft and objects, such as crop dusters or hot-air balloons, and then take action to avoid them. Operators also have to determine how drones can land safely if they lose communications with people on the ground.

BNSF isn’t ready to reveal how it plans to overcome these challenges, said Graetz, an airplane pilot. The company and its partners are working on the final proposal to the FAA for full operation beyond line of sight, he says. Today, some of the railroad’s methods are low tech, such as emails, phone calls and visits to small airports along the rail route to warn people of drone flights.

“There’s the process of good old shoe leather to get to know the airport managers and spreading the news about what we’re doing,” he said.