Every year since 1983, the California International Marathon has begun in Folsom and ended at the state Capitol, crossing the Union Pacific track on L Street.
Last year, the railroad had declined to allow participants in the Kaiser Permanente Women's Fitness Festival half marathon to cross its track in midtown Sacramento, forcing the cancellation of the June race.
Some feared it could alter the course of CIM, which brings thousands of participants and millions of dollars to the local economy.
Scott Abbott, executive director of the Sacramento Running Association, said the railroad recognized how important the marathon was to the community.
"We're appreciative of the relationship we've had and that they've come on board to support our event," he said.
Every year since 1983, CIM has begun in Folsom and ended at the state Capitol, crossing the Union Pacific track on L Street. Race organizers had always worked with the railroad to pause rail traffic during the race to ensure safe passage for the runners.
Last year, however, the railroad didn't grant safe passage for the marathon until November, a month before the event.
The railroad never offered a specific reason for the change, but race organizers said things got more complicated after a fatal crash involving a veterans parade float in Midland, Texas, in 2012. Four veterans of the Iraq and Afghanistan wars were killed when a Union Pacific train struck the back of a flatbed truck carrying them and their spouses to a banquet in their honor.
National Transportation Safety Board investigators found that the event's organizers failed to notify the railroad of their parade route.
California leads the nation in fatalities at railroad crossings and along tracks, according to Operation Lifesaver, a nonprofit rail safety education group.
According to Federal Railroad Administration statistics, 33 people were killed and 45 injured at railroad crossings in California in 2014. Another 93 people were killed and 52 injured along railroad tracks.
Rerouting the California International Marathon around the crossing in midtown Sacramento would require a drastic change in its traditional course, something its organizers wanted to avoid.
The marathon is nationally regarded as an optimal course for runners hoping to qualify for the Boston Marathon and Olympic Trials because of its net downhill elevation and reliably cool weather. In the generally flat Sacramento region, the downhill is largely due to the race start at a higher elevation in Folsom and routing the point-to-point course down to the Capitol.
As a way of promoting their fast course, the marathon's organizers annually give late registration benefits to runners whose recent marathon times are within five minutes of qualifying for Boston. They are also offering financial bonuses to those who qualify for the 2016 Olympic Trials at this year's event.
This year, runners will see a new presence at the race in the form of Union Pacific, a first-time sponsor that will join banks, shoe stores, health care organizations and other local businesses.
The railroad hasn't guaranteed the race safe passage every year: According to Castillo, the request will still be reviewed annually on a case-by-case basis.
Abbott said he's confident that this year's arrangement will stick.
"What we've worked out is a win-win for everybody," he said.
Kevin Yamamura of the Sacramento Bee contributed to this story.