THE negotiators came to the deal just before midnight on Thursday.
A smaller team of British negotiators led by Alan Paul agreed on the final version of the Hong Kong Court of Final Appeal Bill at 11.45 pm, said a source close to the talks.
The team slipped into the Chinese office of the Joint Liaison Group (JLG) in the China Resources Building in Wan Chai after a meal at Government House at about 9 pm.
To avoid reporters, Mr Paul and his Chinese counterpart, Chen Zuo'er, said after the day's nine-hour meeting that they would keep in touch.
The two sides had already agreed on the draft bill on Wednesday when they resumed talks following a three-day round last week.
Thursday was largely devoted to the fine print while another team of experts studied the text of the five-point agreement.