Joseph Rushmore for HuffPost One of the two breaks in the temporary levee in Lumberton, North Carolina, that failed Sunday.

LUMBERTON, N.C. — As Hurricane Florence took aim at the North Carolina coast and threatened to dump extreme amounts of rain across the state, this small city along the Lumber River came up with a desperate plan to prevent getting inundated by floodwaters for the second time in as many years.

Early last week, city officials requested permission from CSX Corp., one of the nation’s largest railroad companies, to construct a temporary sandbag berm across the railroad tracks that run under Interstate 95 in southwest Lumberton, filling a gap in the city’s levee system.

Not only did CSX refuse to allow the city to build the berm, it also threatened to take legal action if the city did, multiple people with knowledge of the situation told HuffPost. It wasn’t until local officials petitioned Democratic Gov. Roy Cooper to intervene that they were able to begin construction of the makeshift wall late last week.

Local leaders contacted Cooper’s office and the state Department of Public Safety on Thursday as Florence loomed off the coast of Wilmington and forecasts called for at least 2 feet of rain in the southeastern part of the state. Early Friday, Cooper issued an emergency order greenlighting construction of the berm at the railroad intersection, Sadie Weiner, a spokeswoman for the governor, told HuffPost via email.

“CSX officials who were contacted did not consent to allowing for sandbagging of the tracks, arguing that there was no proof that it would work and that it would cause significant damage to their tracks,” Weiner wrote. “Upon further consultation and advice of local and state emergency management, the Governor issued an emergency order on Friday morning to allow for the construction of a temporary berm at the CSX railroad intersection.”

Joseph Rushmore for HuffPost A temporary levee of dirt, gravel and sandbags was built over the railroad track in Lumberton over the weekend in an attempt to hold back Lumber River floodwaters.

Bill French, Lumberton’s director of emergency services, confirmed that CSX had threatened the city if it took action without its permission. Cooper “stepped in and helped us to sort of make us immune from prosecution,” he said. It was only after the order came down that CSX was cooperative and helpful, he said.

The order allowed the city’s public works department, members of the National Guard and dozens of civilian volunteers to get started on a sandbag berm to plug the levee gap on Friday ― but at that point, Florence had already hit coastal Carolina as a Category 1 hurricane.

Stephen McIntyre, a local attorney with knowledge of the eleventh-hour undertaking, told HuffPost it is “unfortunate that CSX proved to be such an obstacle to the protection and the safety of so many people’s lives along with their homes, businesses, and places of worship.”

The company’s “disregard for the people of Lumberton,” he added, led to “monumental efforts” by numerous individuals ― in the middle of the slow-motion storm ― to protect the west and south parts of town.

“I am sure that the last-minute efforts that were made bought time and saved some lives and property, but if CSX had been cooperative, we could have done so much more sooner,” McIntyre said.

Joseph Rushmore for HuffPost Water flows through a break in the temporary levee Tuesday.

As rains continued to pound the region and the Lumber River swelled on Sunday, water spilled over the sandbag berm. Crews with bulldozers drove back and forth through muddy floodwater, working frantically to reinforce the wall with loads of loose sand.

In the end, the berm failed to hold back the floodwaters. Emily Jones, a spokeswoman for Robeson County, confirmed to HuffPost that the barrier broke around 2 p.m. Sunday. She urged residents in low-lying areas to “get out now.”

Like everyone else in Lumberton, the railroad knew of the potential consequences if the gap in the levee was not plugged. After all, it was at this very site on the railroad’s property that water from the Lumber River poured into the city during Hurricane Matthew in October 2016, causing catastrophic flooding that displaced more than 1,500 residents for months. Charles Ivey, a 76-year-old Lumberton resident, died after falling into the water at his home.

And yet, CSX fought construction of a temporary bank on the rail line, causing a delay that locals say put public safety at risk.

A CSX spokeswoman told HuffPost she was not aware of any threat of litigation made against the city. As for the request to install the berm, she said CSX had to keep the rail line ― a major route to the coastal town of Wilmington, which took a direct hit from Florence ― open the week before the storm to ensure that hazardous materials in the area where shipped out and that emergency rescue equipment could make it in.

The spokeswoman added that the company was in constant communication with Lumberton officials and provided safe access to the site once the rail line was shut down Friday, suggesting that local officials would have been able to move forward with construction of the berm without an emergency order from the governor.

City Councilman John Cantey Jr., who represents a predominantly African-American precinct in south Lumberton, said he understands a company trying to protect its operations but not at the expense of an entire community. CSX’s initial refusal, he said, tied the city’s hands.

“We were really stuck in a barrel,” he said. “The water’s coming. We can’t stop it.”

Joseph Rushmore for HuffPost Gloria Freeman and her children, Bella and Cullen Jr., sit on their porch with Johnny Oxdine as floodwaters fill their yard in Lumberton.

Cantey is among those who lost his house in 2016. His home and hundreds of others flooded again over the weekend. It’s an outcome the city fought hard to try to avoid a second time.

In the end, it’s unclear if CSX’s alleged delay made a difference. But Cantey expects that if local residents had had more time, they could have done a better job building the temporary berm or come up with additional protective measures.

In the nearly two years after Matthew, the city has worked toward a permanent solution. It secured a $1.25 million grant to build floodgates at the railroad underpass, with work slated to start next year, The News & Observer reported. The Federal Emergency Management Agency has approved a floodgate for the site, French said.

Joseph Rushmore for HuffPost Mobile homes are surrounded by floodwater in Lumberton.

“That will prevent [flooding] from happening ever again,” he said.

As he spoke, muddy water continued to pour from the Lumber River into some of the city’s poorest neighborhoods. As of 2017, about 35 percent of Lumberton’s residents were living below the poverty line.

The sun was out Tuesday, but floodwaters still raced past half-submerged cars and mailboxes and swirled around houses, some of them still vacant and boarded up from flooding during Hurricane Matthew. On a street in west Lumberton, families stood in shin-deep water as they chatted with neighbors. And at a flooded strip mall on West 5th Street, a flashing sign indicated that a nail salon inside was open. It clearly was not.

“I still have hundreds of families who aren’t back in their homes, who lost their homes in 2016,” Cantey said. “Excuse me for trying to block up a hole for a couple of days.”

Joseph Rushmore for HuffPost Floodwaters fill William Colville's yard as he points to the level the water reached at its peak in Lumberton.

CORRECTION: The News & Observer was mistakenly identified as the North Carolina Observer.