BEIJING — A peace envoy from Afghanistan met in western China last week with former Taliban officials with close ties to Pakistan’s intelligence agency, in an attempt to keep open the possibility of formal Afghan peace talks, officials said Monday.

The meeting, hosted by China and, in part, organized by Pakistani officials, took place Wednesday and Thursday in Urumqi, capital of the western region of Xinjiang, which has mountainous borders with Afghanistan and Pakistan and is home to many Muslims.

The main representative of the Afghan government was Mohammad Masoom Stanekzai, who was, at the time, a crucial member of the country’s Peace Council, the group charged with exploring talks with the insurgency, and since then has been nominated by President Ashraf Ghani as defense minister. On the other side of the table were three figures from the old Taliban government in Afghanistan, according to current and former officials with knowledge of the discussions who agreed to speak on the condition of anonymity because of diplomatic sensitivities.

Mr. Stanekzai is awaiting confirmation as defense minister and has been the architect of efforts by the government to begin formal peace negotiations.