HONG KONG — An employee of Britain’s consulate in Hong Kong who had been detained in mainland China for weeks has been released, the police said on Saturday.

The employee, Simon Cheng, disappeared on Aug. 8, during a business trip to Shenzhen, a mainland Chinese city bordering Hong Kong, according to his family and his girlfriend. The Chinese government said on Wednesday that Mr. Cheng, a 28-year-old trade officer, had been held under administrative detention, without specifying what, if anything, he was alleged to have done wrong.

In a post Saturday morning on the social platform Weibo, the Public Security Bureau of Shenzhen’s Luohu District said that Mr. Cheng had confessed to unlawful activities, and that he was released on Saturday after his 15-day detention ended. The statement did not say what the alleged unlawful activities were.

Mr. Cheng’s family said in a brief post on Facebook that he had safely returned to Hong Kong and had “no external injury.” They said that neither he nor the family would speak to the news media for now. “Please let Simon rest,” they said.