New Jersey Transit and its rail engineers union have tentatively agreed to a new labor contract, averting a possible strike.