The deal comes some two weeks before it was due to be reached and must still be passed in Congress.