President Donald Trump has opened the door to an increase in US troops in Afghanistan as part of a retooled strategy for the region.

In a speech offering few specifics, Mr Trump promised a stepped-up military campaign against Taliban insurgents who have gained ground against the US-backed Afghan government, and he singled out Pakistan for harbouring militants.

"We are not nation-building again. We are killing terrorists," he said in a prime-time televised address at a military base outside Washington.

Mr Trump ran for the presidency calling for a swift US withdrawal from Afghanistan, and he acknowledged that he was going against his instincts in approving the new campaign plan sought by his military advisers.

"The consequences of a rapid exit are both predictable and unacceptable," he said.

"A hasty withdrawal would create a vacuum that terrorists, including ISIS and al-Qaeda, would instantly fill."

The Republican president, who has criticised his predecessors for setting deadlines for drawing down troops in Iraq and Afghanistan, declined to put a time line on expanded US military operations in Afghanistan.

Mr Trump now inherits the same challenges as George W Bush and Barack Obama, including a stubborn Taliban insurgency and a weak, divided government in Kabul.

He is laying the groundwork for greater US involvement without a clear end in sight or providing specific benchmarks for success.

US officials said he had signed off on Defense Secretary Jim Mattis' plans to send about 4,000 more troops to add to the roughly 8,400 now deployed in Afghanistan.

Mr Mattis said he had directed the chairman of the Joint Chiefs of Staff to carry out the strategy and that he would be consulting with NATO and US allies, several of which had also committed to increasing troops.

The Taliban warned that Afghanistan would become a "graveyard" for the US after Mr Trump’s speech.

"If America doesn't withdraw its troops from Afghanistan, soon Afghanistan will become another graveyard for this superpower in the 21st Century," Taliban spokesman Zabiullah Mujahid said in a statement.

Mr Trump also laid out a tougher approach to US policy towards Pakistan.

Senior US officials warned he could reduce security assistance for Pakistan unless the nuclear-armed nation cooperates more in preventing militants from using safe havens on its soil.

"We can no longer be silent about Pakistan's safe havens," Mr Trump said.

Pakistan has much to gain from partnering with our effort in Afghanistan. It has much to lose by continuing to harbour terrorists

Mr Trump expanded the US military's authority for American armed forces to target militant and criminal networks.

He said that US enemies in Afghanistan "need to know they have nowhere to hide - that no place is beyond the reach of American arms".

A US-led coalition invaded Afghanistan and overthrew the Islamist Taliban government for harbouring al-Qaeda militants who plotted the 11 September attacks.

However, US forces have remained bogged down there through the Bush and Obama presidencies and now Mr Trump.

About 2,400 US forces have died in Afghanistan since the invasion.

The United States' NATO allies have welcomed Mr Trump's commitment, with Secretary General Jens Stoltenberg saying the organisation "remains fully committed to Afghanistan."

"I am looking forward to discussing the way ahead with Secretary Mattis and our Allies and international partners," he said.

NATO has 12,000 troops in Afghanistan, and 15 countries have pledged more, Mr Stoltenberg added.

Britain has said the US commitment is "very welcome", while Germany welcomed the announcement but said it will not immediately send more troops to Afghanistan.