Long Island Railroad
Commuters leave a Long Island Railroad train at Pennsylvania Station in New York July 15, 2014. Reuters/Shannon Stapleton

(Reuters) - A threatened strike on New York's Long Island Rail Road was averted on Thursday when the transit authority and labor unions reached a tentative contract deal, bringing relief to thousands of riders who had been dreading a painful commute.

The announcement came after Governor Andrew Cuomo urged leaders from the state-controlled Metropolitan Transportation Authority and the eight unions representing about 5,400 rail workers to meet at his New York City office to resolve their differences.

"There's no doubt there was a very wide gulf that had to be crossed and the good news is that they did," Cuomo said at a press conference where he was flanked by Thomas Prendergast, the MTA's chairman and CEO, and Anthony Simon, the unions' chief negotiator.

With less than three months to go before the November elections, the deal was widely viewed as a political victory for Cuomo. The governor appeared relaxed, swapped jokes with reporters, and suggested that stepping in to solve a crisis was something he did on top of his "day job."

"If there is a crisis and I can be of help, I believe that is my role," he said.

Experts warned that the unions, however, may find themselves haunted in the future by their concessions.

The unions had threatened to walk out over the weekend, leaving roughly 145,000 weekday riders on the nation's busiest commuter railroad scrambling to travel between New York City and the suburbs and harming the region's businesses.

Cuomo said the deal fairly compensates "valued employees," who do an often dangerous job, without requiring an additional fare increase or straining the transit system's capital repairs and improvement program.

The contract gives existing railroad employees a 17 percent pay raise over 6 1/2 years but asks them to pay contributions toward their healthcare benefits for the first time. It still must be ratified by union members and approved by the MTA's board.

Cuomo said both sides had compromised on the contract, which was based on recommendations made by two emergency arbitration boards appointed by President Barack Obama. The workers had been without a contract since 2010 and the new deal will retroactively cover the past four years.

The MTA, which previously rejected the board recommendations, agreed to give the pay increase over 6 1/2 years rather than the seven in its last offer.

The unions gave up their resistance to future hires being asked to pay more toward their pensions and having slower wage increases than current employees. The unions had argued this would create an unfair two-tier system.

Political analysts said clearest winner may be the governor.

"It looked like things were not going well and then it looked like he then got in the middle and then things got better," said Lee Miringoff, the director of the Marist Institute for Public Opinion. "It sure does a lot better for him than having a railroad strike during his campaign."

Gregory DeFreitas, a labor expert at Hofstra's Long Island University, said the unions' agreeing to have future hires join on less generous terms could erode support among workers.

"For years to come, they are going to be dealing with simmering irritation of newer workers that they've got a raw deal and the older workers sold them down the river," he said.

Commuters and businesses reacted to the news with relief.

"Amen! Amen! Amen!" Ken Stein, president of the Sayville Ferry Service, said in a telephone interview. He feared a strike would harm his business, which typically ferries 5,000 passengers - 40 percent of them LIRR riders - from Long Island to Fire Island on a busy July weekend day. "A very big 'phew!'"