NEW YORK (CBSNewYork) — There was handshaking and back-patting all around Thursday, after Gov. Andrew Cuomo helped broker a deal between the Metropolitan Transportation Authority and the Long Island Rail Road unions to avoid a potentially crippling strike.

With MTA Chairman Thomas Prendergast and the unions’ chief negotiator, Anthony Simon, seated by his side, Cuomo said Thursday that a “compromise by both parties” had been reached earlier Thursday.

“It is my pleasure to announce today that we have settled a four-year dispute dealing with the Long Island Rail Road labor unions,” Cuomo said.

MORE: Guide To Surviving The Strike | What Both Sides Wanted | Join The #LIRRStrike Conversation

The LIRR’s unions representing 5,400 workers were threatening to strike starting at 12:01 a.m. Sunday if a deal wasn’t reached, and a work stoppage seemed likely earlier this week when negotiations broke down.

The two sides returned to the table Thursday at Cuomo’s Manhattan office, who said he began participating in talks directly after the two sides met Wednesday but failed to come to an agreement.

The governor had previously said he wouldn’t intervene in the contract dispute.