A border security program to X-ray every train rolling into the country has prompted as much as $400 million in fines against U.S. railroads, which are held responsible for the pungent bales of marijuana, tight bundles of cocaine, and anything else criminals cram into the boxcars and tankers as they clickety-clack through Mexico.

Union Pacific, the largest rail shipper on the U.S.-Mexico border and the largest recipient of fines, refuses to pay what now amounts to more than $388 million in fines, up from $37.5 million three years ago when the screening began. In federal litigation the railroad argues that it's being punished for something it cannot control: criminals stashing illegal drugs in rail cars in Mexico.

"Our actions should be applauded, not punished," said UP vice president Bob Grimaila. Union Pacific spends $3.6 million a year on its own police officers, and has spent another $72.5 million supporting federal efforts on the U.S.-Mexico border, building observation towers, training federal law enforcement officers, adding fencing and lighting at border crossings and developing computer profiles to identify drug traffickers.

The Justice Department also says UP, which owns 26 percent of Mexico's railroad Ferromex, is responsible for controlling the trains in Mexico. But the railroad says it cannot be expected to "send unarmed personnel into Mexico to battle Mexican drug cartels that maliciously murder and wage a war against the Mexican military."

The railroad's argument may be gaining traction: The federal government recently signed a partial settlement with the railroad, releasing 10 seized rail cars in exchange for $40,000, and agreed to return to negotiations with the railroad, according to court records. There was no admission of wrongdoing, and Union Pacific agreed to remove any hidden compartments in the railcars.

In addition, the railroad's own commissioned police force is now working with Mexican law enforcement, tracking back illicit shipments to their source and targeting them. Mexican Army officials say that in March, using Union Pacific information and U.S.-provided screening machines, they seized 1,350 tons of marijuana in two different tank cars on trains en route from Aguaruto, Sinaloa to El Paso, Texas.

But motivated smugglers bypass the security. Mexico's powerful drug cartels, whose violence has cost 35,000 lives since late 2006, earn an estimated $25 billion a year selling drugs in the U.S. The 8,000 trains that enter and exit the U.S. each year through 8 border crossings offer a fast track to those lucrative profits.

All ocean, air and land transporters, including railroads, are subject to fines of $500 per ounce of marijuana and $1,000 per ounce of heroin or cocaine if U.S. Customs and Border Protection agents find the drugs in their cargo — this under a 1930 law requiring accurate manifest reports on everything aboard.

In congressional testimony in April, two different CBP assistant commissioners said they have the "capability" to screen 100 percent of rail traffic coming into the U.S. And last month, during President Obama's first trip to the border, his spokesman Jay Carney told reporters: "For the first time, we are screening 100 percent of southbound rail shipments to seize guns and money going south, even as we go after the drugs that are heading north."

Federal officials refuse to say if those inspections have any impact.

"We will not be able to provide you with a visit to a railcar inspection facility. We also will not be able to provide you with statistics or even anecdotal information on railcar seizures because of pending litigation," said spokesman William Brooks.

But calculations based on the fines indicate that more than 20 tons of marijuana has been found on Union Pacific trains in the past two years. And train screening in several Texas cities is hard to miss: Several times a day, two miles of dusty steel cars roll through low-level gamma ray radiation screening machines operating next to busy streets.

At the border, with brakes shrieking, rails screeching and whistles blasting, trains are pulled through a sliding, rusted gate into the U.S. with a Mexican locomotive that often has been traveling for days across Mexico's vast network of rail lines. About 15 feet into the U.S. the Mexican locomotive disconnects, a U.S. locomotive connects, and the train is pulled through the screening station.

Inside an adjacent white shed, federal agents, much like airport baggage screeners, stare at x-ray images of each car as they pass at about 5 mph. Images of the railcars, along with a digital video snapshot of each car's identification number, are saved.

"The idea is to keep that train moving, moving, moving, no stops," said Nelson Bolido, president of the Border Trade Alliance. "The last thing you want to do is stop in Mexico in the middle of a downtown. Cargo that's not moving is cargo at risk."

The images are distinct. A silhouette of a human body is fairly obvious. Drugs can be trickier if carefully packed into the skeleton of the rail car, especially those that have been modified with false walls or floors, or holes cut into center beams with welding torches.

While CBP agents scan the train, the Mexican crew, a few tired men in coveralls, heads bowed, hands in pockets, walk back through an open gate into Mexico. The locomotive remains in the U.S. awaiting a string of southbound cars. When the screening is finished, the train pulls forward, the border gate is closed and the U.S. rail company conducts its own screening using their own drug sniffing dogs and armed cops.

If they spot something, they report it to CBP — and often receive another fine.

With increased security at the border, some smugglers who use trains are taking a short detour. A few miles past one border screening station, gravel around the railroad tracks is littered with cut red plastic ties — each stamped with a serial number — that were once used to seal the cargo.

"What we are seeing is the illegal activity is going around the area where CBP is checking and walking through the desert and getting on a train a little further down the track," said Sheriff Arvin West of Hudspeth County, Texas.

There have been several high profile busts.

Last fall, for example, drug sniffing dogs alerted agents there was marijuana aboard a train from Mexico that was rolling slowly through the X-ray machine into Eagle Pass, Texas, according to federal court records. Agents delicately broke open sacks labeled "titanium pigments" and found a whopping 11 tons of marijuana worth $22 million. It was a huge find, and police wanted to know whose it was. A few weeks later, after following the train, police caught seven men whose clothes and skin were covered with red dust from the pigment that had been wrapped around the marijuana.

The investigation — called a controlled delivery — was a rare example of complex and expensive detective work between the railroad and federal agents. More common are simple seizures, like the June, 2010 discovery of 9,000 pounds of marijuana hidden in an open-top rail car — known as a gondola — at the Calexico, Calif. border crossing.

The X-ray image looked unusual, and drug sniffing dogs helped locate the marijuana, 352 wrapped packages under layers of glass, dirt and wood. Ten more packages hidden in two backpacks were found on a second rail car. The street value was estimated at $9 million.

CBP seized the narcotics. The shipment of glass, dirt and wood was sent back to Mexico.