How did Hong Kong become a country?

Hong Kong is not a country, but a Special Administrative Region (SAR) of China. It was formerly a colony of the British Empire until July 1, 1997.