That the Taliban leader was personally developing ties with both Iran and Russia signaled a stunning shift in alliance for the fundamentalist Taliban movement, which had always been supported by the Sunni powers among the Arab gulf states and Pakistan.

But times were changing with the American drawdown in Afghanistan, and Mullah Mansour had been seeking to diversify his sources of money and weapons since taking over the Taliban leadership in 2013. He had made 13 trips to Dubai, United Arab Emirates, and one to Bahrain, his passport showed, but also at least two visits to Iran.

Set on expanding the Taliban’s sway in Afghanistan, he was also preparing to negotiate an end to the war, playing all sides on his terms, according to both Afghan officials with close knowledge of the Taliban and the former Taliban commander close to Mullah Mansour’s inner circle.

It was that ambitious expansionism that probably got him killed, they said.

“Mansour was a shrewd politician and businessman and had a broader ambition to widen his appeal to other countries,” said Timor Sharan, a former senior analyst of the International Crisis Group in Afghanistan who has since joined the Afghan government.

Mullah Mansour had been tight with the Iranians since his time in the Taliban government in the 1990s, according to Mr. Kohistani, the military analyst. Their interests, he and other analysts and Afghan officials say, overlapped in opium. Afghanistan is the world’s largest source of the drug, and Iran the main conduit to get it out.

Iran’s border guards have long fought drug traffickers crossing from Afghanistan, but Iran’s Revolutionary Guards and the Taliban have both benefited from the illicit trade, exacting dues from traffickers.

The main purpose of Mullah Mansour’s trips to Iran was tactical coordination, according to Bruce Riedel, a former C.I.A. analyst and fellow at the Brookings Institution in Washington. At the time, in 2016, the Taliban were gearing up for offensives across eight Afghan provinces. Farah was seen as particularly ripe fruit.