WARSAW—Poland released a local ex-counterintelligence official who had been detained on charges of spying for China, as Polish and Chinese ministers met in an effort to ease tensions between Beijing and one of the U.S.’s closest allies in Europe.

Piotr Durbajlo, former deputy director of Poland’s Internal Security Agency, was set free on Tuesday on a bail of 120,000 Polish zloty ($31,480) following a ruling on July 5, the prosecution said in an email. The end of Mr. Durbajlo’s pretrial detention came within hours of a visit...