The investigation centers on five officers in the Changping District, a northern suburb of Beijing. Mr. Lei was detained outside a Beijing foot massage parlor on the night of May 7, according to official police accounts at the time. The term “massage parlor” in China often refers to a brothel.

One of the most detailed official accounts appeared on May 11 in People’s Daily, the Communist Party newspaper. The officer in charge of the Dongxiaokou station in Changping, Xing Yongrui, said in an interview with the paper that the police had detained Mr. Lei in an anti-prostitution raid. Mr. Xing said Mr. Lei had bitten police officers and tried to escape twice. It took five officers 20 minutes to subdue Mr. Lei, Mr. Xing was quoted as saying.

The police said Mr. Lei had a heart attack in custody and was declared dead at a hospital, according to Chinese news reports. A report by Xinhua, the state news agency, quoted family members as saying that they had seen bruises on Mr. Lei’s head and arms.

On Wednesday, the Beijing Procuratorate said on its official microblog that the preliminary investigation into the episode had been completed, and that Mr. Lei “was suspected of visiting a brothel and died after the police took enforcement measures.”