Pakistani Taliban militants have freed a Chinese engineer held captive for nearly six months, officials said Sunday, as fears rose over the safety of an abducted American threatened with imminent death by his kidnappers.

It was not clear if a ransom was paid or militants were freed in exchange for Long Xiaowei's release, although the Taliban claimed it was a goodwill gesture to the government after it agreed to help enforce Islamic law in parts of Pakistan's northwest in ongoing peace talks. Long's release also came days before a planned visit to China by Pakistani President Asif Ali Zardari.

A string of recent attacks on foreigners — including the apparent beheading of a Polish geologist — have underscored the deteriorating security conditions in Pakistan, a critical U.S. ally in the fight against terrorism, as it battles al-Qaida and Taliban fighters along its border with Afghanistan.

On Friday, the kidnappers of American U.N. official John Solecki threatened to kill him within 72 hours and issued a 20-second video of the blindfolded captive saying he was "sick and in trouble."

U.N. officials said Sunday they were still trying to establish contact with the gunmen who seized Solecki on Feb. 2 in Quetta, a southwestern city near the Afghan border.

The kidnappers have identified themselves as members of the previously unknown Baluchistan Liberation United Front, indicating a link to separatists rather than to Islamists. The captors have demanded the release of 141 women allegedly held in Pakistan.

Pakistan Interior Ministry chief Rehman Malik has denied that the 141 are being held.

Baluchistan provincial government spokesman Syed Kamran said it was offering a $31,363 reward "for any information leading to the recovery of the kidnapped U.N. official."

Earlier this month, Polish geologist Piotr Stanczak was apparently beheaded by Islamist militants in a video obtained earlier this month by news media and believed by the Polish government to be authentic. If confirmed, it would be the first killing of a Western hostage in Pakistan since American journalist Daniel Pearl was beheaded in 2002.

The Chinese engineer was freed Saturday and taken to the Chinese Embassy on Sunday morning, said Yao Jing, deputy head of China's mission in Islamabad. Long was in good condition and expected to return to China after a medical checkup, China's Foreign Ministry said.

Yao said he did not know if a deal with struck with the militants.

Long and fellow telecommunications engineer Zhang Guo were kidnapped in August in the Dir region of northwestern Pakistan. They both escaped in mid-October, but Long hurt his ankle and was recaptured, while Zhang got away, China's state-run Xinhua News Agency said.

Pakistani government and military officials either could not be reached or declined comment on what secured Long's freedom.

Paying ransom or freeing militants in exchange for hostages is not unprecedented in the Pakistan-Afghanistan region. However, Muslim Khan, a spokesman for the Pakistani Taliban in the Swat Valley, claimed the militants freed the Chinese captive amid talks with the government over enforcing Islamic law in their area.

Swat, a former tourist haven, is now believed to be largely under militant control despite an army offensive.

Mian Iftikhar Hussain, information minister for the North West Frontier Province, confirmed that authorities were talking to members of the Tehrik Nifaz-e-Sharia Mohammed, or the Movement for the Enforcement of Islamic Law, on ways to implement on-the-books regulations allowing Islamic judicial practices.

The movement is led by Sufi Muhammad, whom Pakistan freed last year after he renounced violence. Muhammad is also the father-in-law of Maulana Fazlullah, leader of the Swat Valley's Taliban. Although Fazlullah has in the past indicated deals with Muhammad don't necessarily apply to his group, his spokesman said Sunday that the Taliban would adhere to any deal reached with Muhammad.

"That was our only demand," Muslim Khan told The Associated Press via telephone. "Once Islamic law is imposed there will be no problems in Swat. The Taliban will lay down their arms."

Although agreeing to an Islamic system is a concession to the insurgents, many civilians in the region would likely welcome the move after years of dissatisfaction with the inefficient secular justice system.

The U.S. has criticized past Pakistani peace deals with Islamist extremists, saying they merely give the militants breathing space.