BEIJING — A prominent Chinese writer and frequent critic of the Communist Party who goes by the pen name Murong Xuecun was detained by police officers in Beijing on Tuesday afternoon, his girlfriend said.

The officers took Mr. Murong away at 5 p.m. and did not release him until early Wednesday, said his girlfriend, Wang Ling, who teaches at a university in Hong Kong. Ms. Wang said Mr. Murong had been “invited to have tea,” a euphemism the Chinese often use to refer to an interrogation session by police officers.

Around 6 p.m. Tuesday, Mr. Murong posted on Twitter, “At the Wanshou Temple police station, waiting for the police to come find me to have tea.” Many Chinese friends anxiously discussed the detention online, and early Wednesday, Mr. Murong posted, “I’ve already safely returned home, thank you concerned friends.” He did not immediately give details of what happened during the detention.

Mr. Murong, 40, whose real name is Hao Qun, returned to his home in Beijing last week from a trip abroad and had expected to be approached by the police. While outside the country, he announced on the Internet that he would turn himself over to the Beijing police when he returned because they had detained several of his friends for gathering at an apartment on May 3 to commemorate the 1989 Tiananmen Square pro-democracy protests. Those protests ended when party leaders ordered a military crackdown in which at least hundreds of civilians were killed. The 25th anniversary of the crackdown was on June 3 and 4 this year.