ISLAMABAD, Pakistan — Pakistani Prime Minister Imran Khan said Monday that he has received a letter from President Trump asking for his government’s help and cooperation in advancing peace talks with the Afghan Taliban insurgents.

Both the Foreign Ministry and Information Minister Fawad Chaudhry confirmed that the letter has been received. Chaudhry said the U.S. president told Khan that relations with Pakistan were “very important” to solving the Afghan conflict, especially in helping to bring the insurgents to the negotiating table.

The letter, which has not been publicly confirmed by U.S. officials, would be Trump’s first direct communication with Khan since the former cricket star took office as prime minister in August. As for indirect exchanges, the two leaders posted angry tweets two weeks ago after Trump told Fox News he had cut aid to Pakistan because it would “take our money and do nothing for us.”

The reported request from Trump came as his special envoy for Afghan peace, Zalmay Khalilzad, was expected to arrive in Pakistan on Tuesday for further talks on the issue. His previous visits have been received cordially but have not resulted in any concrete agreements.

The Trump administration is eager for the peace talks to move forward and the conflict to end after 17 years. Khalilzad has met with Taliban leaders and a variety of regional officials over the past several months, but there has been no breakthrough. The insurgents continue to insist that foreign forces must leave the country under any deal and that they will negotiate only with U.S. officials.

Trump has made numerous critical comments about Pakistan in the past, some of them sarcastic in tone. He suspended military aid last year to the longtime U.S. security ally, saying it had not done enough to rein in a branch of the Taliban insurgents, known as the Haqqani network, that U.S. officials believe shelters inside the Pakistani border with Afghanistan.

In the recent series of tweets, Trump complained that the United States had given hundreds of millions of dollars to Pakistan but that officials there had “never informed us” that Osama bin Laden, the al-Qaeda leader, was living there in a city near a major Pakistani army facility. Bin Laden was killed in a raid by U.S. Navy SEALs in 2011.

Khan, in turn, retorted angrily in a tweet that the “record needs to be put straight on Mr. Trump’s tirade against Pakistan.” He said his country has suffered more than 75,000 casualties in the war on terrorism and agreed to cooperate with the United States in that effort, even though “no Pakistani was involved” in the attacks of Sept. 11, 2001.

Instead of “making Pakistan a scapegoat for their failures,” Khan tweeted, the United States should undertake a “serious assessment” of why, after a war involving hundreds of thousands of NATO and Afghan troops and more than $1 trillion in costs, “the Taliban today are stronger than ever before.”

On Monday, the message reportedly sent by Trump was far more diplomatic and polite, and it couched Pakistan’s role as potentially constructive and helpful in ending the Afghan war, rather than as part of the problem. Pakistani officials, in turn, welcomed the letter.

“Since Pakistan has always advocated a political settlement to end war in Afghanistan, the U.S. decision is welcomed,” the Foreign Ministry said in a statement. “Pakistan reiterates its commitment to play a facilitation role in good faith. Peace and stability in Afghanistan remains a shared responsibility.”

The statement said Trump “has also acknowledged that the war had cost both USA and Pakistan. He has emphasized that Pakistan and USA should explore opportunities to work together and renew partnership.”