KABUL — Afghan President Ashraf Ghani on Thursday announced a unilateral, week-long cease-fire with the Taliban, the latest move in his government’s increasingly urgent bid for peace and a reflection of the insurgent group’s battlefield strength.

Speaking in a televised address, Ghani said that local forces would halt offensive operations against the Taliban beginning June 12, close to the end of the holy fasting month of Ramadan, but would continue to attack the local branch of the Islamic State and other hard-line militant groups. It was the first time an Afghan leader has declared an unconditional cease-fire with the Taliban since the war began in 2001.

The Taliban had no immediate response to Ghani’s declaration.

The unexpected announcement comes at a delicate moment for Ghani and his Western backers, as Afghan forces struggle to demonstrate their strength against an emboldened Taliban, which controls vast parts of rural Afghanistan and has launched an increasingly bloody campaign of terrorist attacks in urban areas. Last month, the militants overran parts of the provincial capital of Farah province in western Afghanistan.

An Afghan official, speaking on the condition of anonymity because he was not authorized to discuss the matter publicly, said the government would extend the period of the truce if the Taliban abides by its terms.

“This cease-fire is an opportunity for Taliban to reflect on the fact that their violent campaign is not winning them hearts and minds but further alienating the Afghan people from their cause,” Ghani said. “With the cease-fire announcement, we epitomize the strength of the Afghan government and the will of the people to achieve a peaceful resolution to the Afghan conflict.”

Under President Trump’s new strategy, an expanded U.S. force is providing hands-on assistance to Afghan units. Although they are more capable and better equipped than in the past, Afghan troops continue to struggle to plan and execute major operations against the Taliban. Last month, the Pentagon’s inspector general reported that local forces had made “minimal progress” in securing Afghans.

The truce follows an unprecedented religious ruling, or fatwa, from a gathering of Afghan clerics this week declaring the insurgency illegitimate and proclaiming that suicide bombings, a frequent tactic of the Taliban, the Islamic State and other militants, are forbidden by Islam.

Ghani is seeking to build momentum around a peace initiative he unveiled this year. Acknowledging the staying power of the Taliban after 17 years of war, the president wants to open peace discussions with leaders of the movement and show his government’s flexibility in accommodating some Taliban demands.

In February, he officially recognized the Taliban as a political actor and proposed a constitutional review as part of a process that could also include cease-fires and other confidence-building measures.

But the Taliban has consistently rejected talks with the Afghan government, reiterating in a letter to the American people in February its openness to negotiations with the United States instead.

In a sign of the challenge Ghani will face in using a political process to bring peace to Afghanistan, a suicide bomber attacked a gathering of religious scholars on Monday and killed 14 people. The local branch of the Islamic State claimed responsibility for the attack.

Andrew Wilder, an Afghanistan scholar at the U.S. Institute of Peace, called the truce a positive step “in what is likely to be a long and difficult peace process.” But he said a lack of trust between the government and the Taliban remains a significant obstacle.

“The ball is now firmly in the Taliban camp to demonstrate, even if just symbolically by agreeing to a one-week Eid cease-fire, that they are also serious about wanting to talk and not just fight,” Wilder said, referring to the religious holiday at the close of Ramadan.

A spokesman for the Afghan Defense Ministry said troops would remain on an “active defensive status” when the truce begins and that he hoped for a positive response. “Otherwise, Afghanistan’s security forces are prepared to foil any threat and defend citizens,” said the spokesman, Mohammed Radmanesh.

David Sedney, a former Pentagon official and Afghanistan expert, said the announcement may offer the Afghan leader, whose government remains reliant on outside aid and whom the Taliban dismisses as a U.S. puppet, a chance to demonstrate his independent leadership.

“While Ghani would not have made the announcement without consulting with or informing in advance the U.S. and NATO, a unilateral cease-fire was not part of the existing U.S. strategy for Afghanistan,” he said.

The U.S. military, which has about 15,000 troops in Afghanistan in a dual mission to support local forces against the Taliban and to conduct unilateral operations against the Islamic State and other transnational groups, said it would abide by the terms of the truce.

“We will adhere to the wishes of Afghanistan for the country to enjoy a peaceful end to the Islamic holy month of Ramadan, and support the search for an end to the conflict,” Army Gen. John W. Nicholson Jr., who commands U.S. and NATO forces in Afghanistan, said in a statement.

U.S. operations against the Islamic State would continue, the U.S. military said.

Even as American officials express a desire for a political end to the war, the Trump administration has not yet shown that it is willing to devote significant political capital to kindling a peace process with the Taliban.

The previous administration held on-again, off-again talks with Taliban representatives as President Barack Obama oversaw a surge of U.S. troops, and U.S. diplomats have continued periodic contacts with the group since then. But under Trump, the effort has suffered from a lack of specialized personnel and from a diplomatic focus on other initiatives such as talks with North Korea. The administration has not said whether it would be willing to withdraw military forces from Afghanistan, a key Taliban demand.

A senior State Department official, speaking to reporters on the condition of anonymity, said the United States would only want to maintain its military presence in Afghanistan as long as conditions required but did not give details.