(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 agreement, New York Governor Andrew Cuomo said.

"It is my pleasure to announce today that we have settled a four-year dispute," Cuomo said at a news conference, flanked by leaders from the eight unions representing about 5,400 workers and the Metropolitan Transportation Authority, which runs the region's public transit.

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

"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, adding that the deal fairly compensates "valued employees," who do an often dangerous job, without requiring a fare increase.

The contract, which gives existing railroad employees a 17 percent pay raise over six and a half years, still has to be ratified by union members and then 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 last four years.

The MTA, which had previously rejected the board recommendations, agreed to give the 17 percent pay increase over six and a half years rather than the seven in its last offer.

The unions gave up their resistance to future hires being asked to pay more towards their healthcare costs and pensions than current employees. The unions had argued this would create an unfair two-tier system.

Political analysts said clearest winner may be the governor himself, who is up for re-election in November.

"It looked like things were not going well and then it looked like he then got in the middle and then things got better," Lee Miringoff, the director of the Marist Institute for Public Opinion, said in a telephone interview. "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 end up eroding 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 were reacting to the news with relief.

"Amen! Amen! Amen!" Ken Stein, president of the Sayville Ferry Service, cheered 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'!"