Union Pacific has resolved part of its long-running dispute with the federal government about fines imposed on the railroad over drug smuggling on trains crossing from Mexico with a $50 million agreement, but the company’s lawsuit challenging the fines remains in place.

The railroad and the U.S. Customs and Border Protection agency announced the agreement Friday covering about $500 million in fines the government had tried to impose and providing a five-year amnesty for Union Pacific. In exchange, the Omaha-based railroad agreed to invest $50 million in efforts to strengthen security at the Mexican border.