Details of the agreement were not immediately announced, but Metropolitan Transportation Authority Chairman Thomas Prendergast said the deal provides a "fair and reasonable contract" that protects commuters and the fiscal health of the MTA.
Chief union negotiator Anthony Simon said his membership was reluctant to strike, but a tough stance was necessary in order to get an agreement.
"This was definitely about the riders," Simon said. "We cared about the financial stability of the railroad as well as the members and their financial stability."
Officials in New York City and Long Island had predicted dire consequences if workers walked off the job. Approximately 300,000 riders used the railroad daily.
Earlier this week it appeared a strike was likely when union negotiators and MTA officials said that they had reached an impasse.
Cuomo, a Democrat who is running for re-election, jump-started the talks on Wednesday when he appealed to both sides to resume negotiating. The governor held discussions with the sides later that day and on Thursday morning summoned them to his office.
President Barack Obama had appointed two emergency boards to help resolve the dispute, in December 2013 and May of this year, but the MTA rejected both nonbinding recommendations. The emergency board's last proposal called for a 17 percent raise over six years while leaving work rules and pensions alone.
The MTA offered a 17 percent wage increase over seven years but also wants pension and health care concessions, which both sides said was the sticking point holding up an agreement.
Ahead of the threatened strike, the MTA released a contingency plan that included shuttling commuters by school bus from selected LIRR stations to subway stops in New York City, and opening several large park-and-ride parking lots, but officials concede a strike would snarl traffic throughout the region and create a commuting nightmare for millions.
The MTA and others also said thousands of employees planned work from home.
The state comptroller, Thomas DiNapoli, had estimated a strike would be a "devastating blow" to a region that is still struggling to recover from Superstorm Sandy and the recession. He estimated economic losses of $50 million a day.