Just days before New York railroad workers were due to strike at the nation's largest commuter railroad, a tentative agreement was reached Thursday.

New York Gov. Andrew Cuomo made the announcement at his Manhattan office after convening a meeting with officials from the Metropolitan Transportation Authority and Long Island Rail Road union leaders to work out the details.

"This is a compromise by both parties after four long years. Compromise by definition means that neither side gets everything that they wanted to get," Cuomo said at a news conference. "We wanted fair compensation for valued employees, and we wanted to make sure that the MTA didn't need to raise fares."

Workers have been without a contract since 2010, and they threatened to walk off the job Sunday unless they could reach an agreement. In all, 300,000 riders use the railroad daily, and Cuomo acknowledged the strike would have left Long Island commuters with few options for transport, which would have contributed to the loss of "tens of millions of dollars per day, not to mention the personal hardship, not to mention the safety concerns."

The tentative deal would give the LIRR's 5,400 employees a 17 percent raise over 6½ years. Employees would be expected to contribute to their health insurance costs, and new employees would work under different wages and pension provisions. The agreement will have to be ratified by the unions' membership.

"The Long Island Rail Road workers are valued employees of the railroad. They work dangerous jobs in many places. ... And we respect them, and we respect their service," Cuomo said.

"This definitely is a fair contract. It's a compromise by all parties to make sure that we continue down the road of a safe and reliable system," said Anthony Simon, general chairman of the United Transportation Union.