In formal terms the answer lies in the second Convention of Peking, signed on 9 June 1898. The ailing Qing Dynasty leased the New Territories to Britain for 99 years, starting 1 July 1898. The new additions were to make up 90 per cent of Hong Kong's land mass. The term of 99 years was fixed almost casually. Both sides believed the new lands would remain British for ever, along with the original colonial possession of Hong Kong island, acquired in 1842. The British empire would never die.
The lease was signed in the midst of a flurry of European colonial expansion in China. Britain did not want to be left out, but it was prepared to let China's rulers save face by not insisting the territory should be ceded in perpetuity.
As early as 1909 Governor Sir Frederick Lugard suggested the New Territories be ceded permanently to Britain as a condition for the return of the British concession of Weihaiwei to China. In the event, Weihaiwei was returned to China in 1930, without any of the conditions suggested by Sir Frederick two decades previously.
When the Qing Dynasty fell and the nationalist government was installed, it declared it would not accept the "unequal treaties" that gave Hong Kong to Britain. The nationalist leader Chiang Kai-shek, with the support of the United States, put pressure on Britain to hand Hong Kong back after the Second World War but Churchill would have none of it.
After the Chinese Revolution, the leaders in Peking had to deal more pressing business than the recovery of Hong Kong. Indeed the territory's existence as a British colony had its uses in providing the Chinese mainland with a window on the rest of the world.
It was not until the mid-1970s that China and Britain started to think about the future of Hong Kong's colonial status. Formally China insisted that it would only take Hong Kong back "when the time is right". It suited China to turn a blind eye to the reality of British sovereignty, while stating that it did not accept the colonial status quo.
It is likely that the Communist Party decided to resume sovereignty following the expiry of the New Territories lease in 1976-7. However the decision was only made known to Britain in March 1979, during a visit to Peking by Sir Murray (now Lord) Maclehose, the Governor. Britain was careful not to let this decision be known and China also kept quiet about it. Some thought had been given to the idea that Britain might maintain its presence in the portion of the colony that was ceded in perpetuity. In the end, Hong Kong without the New Territories was not considered a viable option.
By 1982 negotiations for the return of Hong Kong were effectively under way. Two years of tough bargaining followed, leading to the signing of a Sino-British Joint Declaration under which Britain would withdraw from Hong Kong on July 1 1997.