Afghan refugee families wait to be registered at the U.N. High Commissioner for Refugees repatriation center on the outskirts of Peshawar, Pakistan, as they prepare to return to their home country after fleeing civil war and Taliban rule. (Abdul Majeed/Agence France-Presse via Getty Images)

Stephen J. Hadley, chairman of the board of the U.S. Institute of Peace, was U.S. national security adviser from 2005 to 2008. Andrew Wilder is the institute’s vice president of Asia programs, and Scott Worden is director of Afghanistan and Central Asia programs.

The U.S. bombing of an Islamic State stronghold in eastern Afghanistan last month, and last week’s news of two service members killed in an anti-Islamic State operation, are needed reminders of why we still have troops in Afghanistan. In mountains near those that once hid Osama bin Laden, a terrorist group that seeks to attack the United States is again seeking sanctuary.

The devastating attack on an Afghan army base in Mazar-e-Sharif that killed more than 140 soldiers is a grim reminder of the challenges confronting the Trump administration as it completes its Afghanistan strategy review. How can the United States eliminate international terrorist threats emanating from Afghanistan while the Afghan government is fighting a war of attrition in which the Taliban has gained the upper hand?

During a U.S. Institute of Peace visit to Pakistan and Afghanistan last month, we met with senior officials and civil society and business leaders. Based on those discussions, we believe the solution lies in Afghan and regional politics, not just on the battlefield. The United States should shift its strategy to prioritize reaching a political settlement based on the Afghan constitution among all Afghan groups, including the Taliban. In doing so, the Trump administration can move from a policy of avoiding failure to one of achieving success.

The right strategy should include four main components.

First, the United States should use its existing counterterrorism capability to destroy all Islamic State and al-Qaeda elements in Afghanistan. It must also enhance its support for the Afghan security forces so that they can deny the Taliban strategic battlefield successes. More Afghan special forces, greater close-air support capability and better intelligence capacity are needed to maintain control of Afghanistan’s major population centers and transport arteries. An Afghanistan that can clearly survive without a peace settlement is more likely to achieve one.

Second, such military assistance must be part of a political strategy to address the drivers of conflict that have allowed the Taliban to make steady territorial gains. A modest increase in military support will not stabilize Afghanistan if the Afghan government does not take tough measures to reduce the cancer of corruption. It must win greater public support by building the economy in a way that creates jobs, and conduct credible elections that will provide greater legitimacy for the government and strengthen its position in a future peace process. The United States and Afghanistan should make mutual commitments to support these efforts.

Third, the United States should make clear that a successful outcome will not require military defeat of the Taliban. The goal instead should be an Afghan-led and -owned peace process that produces a political settlement among all elements of Afghan society, including the Taliban. The settlement should protect the human rights of all Afghans as enshrined in the constitution and guarantee that Afghan territory will never be used to support international terrorism. This requires that the Afghans, Afghanistan’s neighbors, and the United States and its international partners agree on a framework for an inclusive peace process. As part of this process, the United States, in close coordination with the Afghan government, should consider direct talks with the Taliban.

Finally, the United States should work to rebuild a regional consensus for a stable Afghanistan. The Trump administration should revitalize an international contact group to align all relevant outside powers. The key message for Russia, China and Iran is that we want a political settlement. Our forces are there only as long as requested by the Afghan government. Once the country is stable, free of terrorist groups and able to prevent their return, we can discuss a timetable for the reduction and gradual withdrawal of our military presence.

Pakistan should be a strategic ally of the United States. But Pakistan hosts the Afghan Taliban leadership and provides material support. The United States should address Pakistan’s legitimate strategic concerns about threats emanating from Afghan territory, the burden of hosting Afghan refugees and the need for better relations with India. In return, Pakistan must take measures to constrain the Taliban, starting with withdrawing support and halting the Taliban’s freedom of movement within Pakistan. If no progress is made, the United States and its allies should take tough action targeted against those involved in supporting Taliban and transnational terrorist groups.

This strategy would be a cost-effective investment. Prior U.S. spending levels of $120 billion per year have been reduced to $20 billion to $25 billion. This is a small sum compared with the estimated $1 trillion-to-$2 trillion loss from another 9/11-scale terrorist attack on the U.S. homeland.

A stable Afghanistan continues to be a top U.S. national security priority. In this region of the world, the current Afghan government is a rare and willing ally at the epicenter of the fight against the Islamic State and international terrorism. Its collapse would again create a haven for terrorist organizations that would threaten the United States and could destabilize nuclear-armed Pakistan.

The long-term goal of a prosperous Afghanistan is worthy of U.S. and international support. But that outcome is largely in the hands of the Afghans themselves. The immediate U.S. objective should be to end terrorist threats to the United States and our friends and allies emanating from Afghanistan, help Afghanistan stabilize itself and the region, and help initiate a process aimed at achieving a lasting political settlement of the conflict. It’s time to redefine success in Afghanistan from winning the war to winning the peace.