WASHINGTON  -- USinfo-icon President Donald Trumpinfo-icon and visiting Pakistani Prime Minister Imran Khaninfo-icon on Monday agreed that there can be no military solution to the Afghan problem and only a dialogue can bring lasting peace in the warinfo-icon-torn country.

President Trumpinfo-icon said Pakistaninfo-icon was helping the US in the Afghan peace process as he met Prime Minister Khan at the White House for the first time in a meeting.

"There is no military solution in Afghanistaninfo-icon. If you go all out militarily, millions and millions of people will die. There is only one solution and I feel, it's closest that we have been to a peace deal and we hope that in coming days we will be able to urge the Taliban to speak to the Afghan and come to a political settlement," Khan told reporters during a joint mediainfo-icon appearance with Trump at the Oval Office.

Echoing Khan, Trump said what the Pakistan Prime Minister "just said is a very big story" and it is 100 per cent correct.

"We have made a lot of progress over the last couple of weeks and Pakistan has helped us with that progress," he said.

"This is a critical time...What we want is understanding between the countries. I can assure President Trump whatever we are saying, we will be straight with them. There will not ever be any doubt about Pakistan's intent," Khan told reporters.

"Apart from Afghanistan, the country that wants peace in Afghanistan is Pakistan. Pakistan needs stability. We have had 15 years of fighting this war on terror... We desperately want peace and we are happy President Trump has pushed this forward," he said.

Responding to a question on troop withdrawal from Afghanistan, Trump said the US had already withdrawn quite a few.

"We're doing it very slowly, very safely. And we're working with Pakistan and we're negotiating with the Taliban. And we're doing very well in that regard," he said.

The US is working with Pakistan to find a solution to Afghanistan's problem, the President said.

Asked if all US troops will be out of Afghanistan by election day next year, Trump said, "Well, I don't know. We're moving a lot of them out," he said.

Trump said Pakistan was going to help "us out to extricate ourselves. We're like policemen".

Asserting that the US is not fighting a war, Trump said if Americainfo-icon wanted to fight a war in Afghanistan and win it, it can win it in a week.

"I just don't want to kill 10 million people...I have plans on Afghanistan where if I wanted to win that war, Afghanistan would be wiped off the face of the earthinfo-icon. It would be over in, literally, 10 days. I don't want to go that route. ...Nor do we want to be policemen...We've been there for 19 years in Afghanistan. It's ridiculous," Trump said. 

Khan's visit comes at a time when talks between the US and Afghan Taliban are thought to have entered a decisive phase. Pakistan's efforts have been appreciated for facilitating peace talks with the Taliban.

Ties between the US and Pakistan strained after Trump, while announcing his Afghanistan and South Asiainfo-icon policy in August 2017, hit out at Pakistan for providing safe havens to "agents of chaos" that kill Americans in Afghanistan and warned Islamabad that it has "much to lose" by harbouring terrorists.

The relations between Pakistan and the US have remained tense during Trump's tenure. The US president has publicly said that Pakistan has given us "nothing but lies and deceit" and also suspended security and other assistance for backing terror groups.