President Donald Trump, speaking at a White House meeting with visiting Pakistani Prime Minister Imran Khan, said on Monday the United States is working with Islamabad to find a way out of the war in Afghanistan.

Trump held out the possibility of restoring U.S. aid to Pakistan, depending upon what is worked out, and offered assistance to Islamabad in trying to ease strained ties with India.

Khan told Trump there was only one solution for Afghanistan and that a peace deal with the Taliban was closer than it had ever been. He said he hoped in the coming days to be able to urge the Taliban to continue the talks.

The United States views Pakistan’s cooperation with a deal to end the 17-year-old war as essential but the two countries have a complicated relationship.

Trump wants to wrap up U.S. military involvement in Afghanistan and sees Pakistan’s cooperation as crucial to any deal to end the war and ensure the country does not become a base for militant groups like Islamic State.

Washington wants Islamabad to pressure Afghanistan’s Taliban into a permanent cease-fire and participation in talks with the Afghan government.

Trump last year slashed millions of dollars of security assistance to Islamabad, which it accused of serving as a safe haven for militants. Pakistan has denied the accusations.

Authorities in Pakistan last week arrested Hafiz Saeed, the alleged mastermind of a 2008 militant attack on the Indian city of Mumbai who has been designated a terrorist by the United States and the United Nations. More than 160 people were killed in the four-day siege.

But Pakistan has not released Shakil Afridi, the jailed doctor believed to have helped the CIA track down former al-Qaida leader Osama bin Laden, whose organization was responsible for the Sept. 11, 2001, attacks on the United States.

India, which in February came close to war with Pakistan over the disputed region of Kashmir and which accuses Islamabad of supporting militants, will be watching the talks in Washington closely.

The Pentagon said Pakistan’s army chief, Gen. Qamar Javed Bajwa, will meet later on Monday with the top American military officer, chairman of the U.S. Joint Chiefs of Staff Gen. Joseph Dunford.

Analysts believe Bajwa will play a key role in behind-the-scenes discussions in which much of the serious business of the visit will take place, with the military looking to persuade Washington to restore aid and cooperation.