FORTUNE -- The strawberries on your cereal. Your laptop, cell phone, and TV. The coal that's burned to power them. The car you drive. The roof over your head. We may work in a knowledge economy, but Madonna had it right: We live in a material world.
That's why the Union Pacific railroad, No. 164 on the Fortune 500, has played a vital role in the U.S. economy since 1862. With $14.1 billion in revenue last year, the UP, which is based in Omaha, is America's largest railroad. Close behind is its chief rival, the Burlington Northern Santa Fe (BNI) (2009 revenues: $14 billion), headquartered in Fort Worth, which was acquired this year by Warren Buffett's Berkshire Hathaway (BRK.A) for $26.4 billion. (Berkshire previously owned about 20% of the company.) The deal put a spotlight on the often troubled railroad business -- in a good way. "It was a vote of confidence in the industry," says Jim Young, the 53-year-old chairman and CEO of Union Pacific. "He sees the long-term value in the rail franchise -- how unique it is in America."
Why would Warren Buffett want to own a railroad? "In business," he has said, "I look for economic castles protected by unbreachable 'moats.'" The economic moats around railroads are the billions of dollars it costs to build them and the fact that the rights of way they need are all but impossible to obtain today. Says Young: "I don't think you'll ever see a railroad built in America again." Because they are the most efficient way to haul freight, railroads should grow along with industrial production. They also have an opportunity to take market share away from long-haul trucks, particularly as fuel prices rise, highway congestion increases, and shippers seek a green alternative.
All those factors make the Union Pacific a good business, despite some recent woes. Its network is unparalleled: It operates 32,094 miles of track in 23 states west of the Mississippi, using 8,350 locomotives and 83,197 freight cars that carry, among other things, grain, corn, soybeans, coal, stone, sand, scrap metal, logs, farm machinery, military equipment, wind turbines, fresh produce, and shipping containers packed with consumer goods. "Building America" is the UP's slogan, and it's not an idle boast.
The trouble is, all that infrastructure requires billions of dollars a year of capital investment. And while railroads do well with steady, predictable growth, anything else can throw them off stride. Economic downturns leave rail companies with costly, idle capacity. Unbridled growth can be an even bigger headache.
It's Young's job to steer the Union Pacific through the peaks and valleys. A gray-haired, plainspoken Omaha native, he is a lifelong company man who says things like: "I think I work for the greatest company in America. Period."
It didn't feel that way when he took over in 2006. The UP was in crisis mode. Demand for shipping had surged and the railroad buckled under the added load. You need five things to run a railroad -- track, yards, locomotives, freight cars, and people -- and none can be mustered in a hurry. "We were aggressive in cutting costs, and it cost us," Young recalls. "We didn't have enough locomotives. We didn't have enough crews." Weather-related calamities, including Hurricanes Katrina and Rita, made matters worse. Bottlenecks developed, troubles cascaded throughout the network, and customers suffered from long delays, as well as lost or damaged goods. Even now, Young seems pained by the memories. "We were, really, last in service. We were the best marketing arm of our competitor. I'm not kidding," he says. "We learned a very, very tough lesson."
Since then Young and his team have restored the railroad's good name. It took new technology, investment in track and equipment (about $10 billion in the past four years), and old-fashioned cheerleading. Young takes to the rails in a custom-built train every few months to meet with some of the UP's 42,000 employees, reminding them how vital they are. "You have to hit the schedules," he says. "This is an unforgiving business."
Customers have taken notice. Last year the HUB Group (HUBG), a $1.6-billion-a-year transportation company, shifted nearly all its business in the West from the Burlington Northern to the UP. "We're seeing about the best rail service I've ever seen," says David Yeager, HUB's CEO, who has been in the business for 35 years. An index of customer satisfaction, which the company watches closely, reached 87%. It had fallen as low as 64% in 2005, just before Young took over.
But just as the UP was getting the trains to run on time, the recession hit. Last year carloads fell 16% from 2008, revenues were down 21%, and net income dropped 19%. "It was phenomenal how quickly things fell off," Young says. He slashed costs: Some 2,000 locomotives were parked at rail yards. "At peak we had $6 billion in assets idled," Young says. But he tried not to cut so deeply that the UP would be caught short by an economic recovery. About 5,300 employees were furloughed, but with a twist: Many were kept on part-time, with health care benefits, so that they would be available when needed.
These days things are looking better. Nearly half the furloughed workers have been recalled, and trains are being brought back into service. Volume is growing for the first time in two years; carloads were up by 13% during the first quarter.
The Union Pacific has also become more efficient. Trains are longer -- on average, 5,800 feet, or more than a mile long -- and instead of just pulling the freight cars, locomotives are distributed throughout the trains so that they push as well. Information technology helps too: Locomotives with GPS track the fuel efficiency of every engineer, and those who use the least fuel get a share of the savings, between $200 and $400 a month.
That has enabled the Union Pacific, with the rest of the railroad industry, to tell a nice-sounding environmental story: The rail industry as a whole carries about 43% of all freight (as measured in ton-miles), but trains consume just 7% of the energy used to move freight. Trucks, by contrast, move 31% of the tonnage but use 66% of the energy. UPS (UPS, Fortune 500), a big customer of Union Pacific, uses trains rather than trucks to move ground packages that travel 750 miles or more. "The economies of steel on steel are better than rubber on concrete," says Kelley Anderson, general manager for rail at UPS.
So are trains "green"? That depends. Young says: "We can move a ton of freight about 435 miles on one gallon of diesel." But the UP's biggest business is shipping coal, America's dirtiest fuel, and the company has lined up with the coal industry in opposing climate legislation in Congress.
Regulation is another worry for Young, who has seen railroads thrive since they were deregulated in 1980. A coalition of freight customers called CURE (Consumers United for Rail Equity) is lobbying in Washington for legislation that would make it easier for shippers to challenge railroads' rates before an obscure regulatory agency called the Surface Transportation Board. Young says re-regulation would be a disaster. "You can call it what you want to, but it is basically price controls," he says. If anything, he'd like to raise prices, so that the UP can continue to invest in its infrastructure. He also wants to get the company's return on capital, which was 8.2% last year, "above a double-digit number."
Still, investors in the company have done very well. Over the past five years shares in the Union Pacific have grown by about 107%, while the S&P 500 index (SPX) is down by about 11%. Analysts say the company will benefit from a gradual economic recovery, but Young isn't counting on it. "My No. 1 concern is the world economy," he says. "I'm trying to make a decision on hiring for the next six months. It's never been more uncertain."