Pakistan’s military says it achieved a major strategic victory over Islamist militants hiding in the Shawal Valley, a thickly forested area bordering Afghanistan thought to be among the last few refuges here for al-Qaeda and the Pakistani Taliban.

Pakistan’s army chief, Gen. Raheel Sharif, visited the area on Friday to congratulate troops for clearing “all peaks” that surround the valley. Now, Sharif said, the army will begin a final assault on the lower elevations.

“We will not stop unless we achieve our end objective of a terror-free Pakistan,” Sharif said in a statement.

After years of bloodshed from terrorist attacks, the Pakistani military launched its offensive in the country’s northwestern tribal areas in June of last year. Since then, army leaders say they have driven militants from much of North Waziristan, which had been a safe haven for terrorist groups that carried out attacks both in Pakistan and Afghanistan.

Pakistan’s interior minister, Chaudhry Nisar Ali Khan, told the country’s Supreme Court on Saturday that 20,000 militants had been killed or wounded since the operation began. An additional 2,500 have been arrested, he said.

Last month, however, Pakistan’s military issued a statement saying it had killed just 2,763 terrorists over the past year.

Pakistan restricts media access to the tribal areas, which makes it difficult for independent observers to assess security officials’ claims.

But Pakistan has experienced a sharp decline in civilian casualties from terrorist attacks so far this year.

Many of the militants from North Waziristan fled across the border into Afghanistan, where violence has been increasing. Others are hiding along the Pakistan-Afghanistan border, officials said.

The Shawal Valley straddles both North and South Waziristan, but it also includes a network of trails and tunnels to Afghanistan.

U.S. drone strikes frequently target the area. In January, a U.S. drone strike mistakenly killed two foreigners who had been kidnapped by al-Qaeda, including American Warren Weinstein.

Weinstein, 73, had been held since 2011 after being kidnapped in Lahore, Pakistan, while working as a contractor for the U.S. Agency for International Development. An Italian aid worker, Giovanni Lo Porto, was also killed in that strike.

Zahid Hussain, an Islamabad-based military analyst, said the Pakistani army is trying to complete its offensive in the Shawal Valley before snow begins falling there in September.

“This is going to be the most critical phase of the North Waziristan operation,” said Hussain, who has made several visits to the area. “It’s a very, very treacherous, mountainous area, and thickly forested, so there is a reason why the army has left it for the end.”

The operation in Shawal Valley is accelerating just days after the Pakistani army concluded its offensive in another border area that was also a refuge for Islamist militants.

According to Pakistan’s Dawn newspaper, that operation in the Tirah Valley in Khyber Agency was successful in “effectively flushing out militants and blocking their crossing points on borders with Afghanistan.”

The Tirah Valley borders Afghanistan’s Tora Bora mountains, to which Osama bin Laden escaped after the fall of the Taliban government in Kabul in 2001.

In an interview with The Washington Post, one military official cautioned that militants can still be found in the most rugged, mountainous areas of the Tirah Valley. Military leaders are debating whether to confront those militants with ground forces or with more airstrikes, said the official, who spoke anonymously because he was not authorized to speak to the media.

In either case, Dawn reported that those areas will become uninhabitable once winter sets in. But some local residents remain skeptical.

“Nothing has been achieved from these operations except displacing hundreds of tribesmen,” said Zar Ali Khan Afridi, a local political activist in Khyber Agency. “The people are relying on the government’s claims, but the military can’t even reveal one name” of a high-profile militant who has been killed.

Nasir Khan, a senior government official in Khyber Agency, counters that about 100 Taliban and al-Qaeda militants and commanders have been killed there in recent weeks. Former Pakistani military leaders say identifying those killed in the operations could spur retaliatory attacks by sleeper cells in Pakistani cities.

Even when the military operation officially ends, however, Hussain and other analysts say they still are not sure whether Pakistan has an effective strategy for making sure militants do not eventually return to the historically lawless tribal areas.

That would require thousands of additional paramilitary border patrol agents as well as sustained effort by the government to boost services. Pakistan’s military will also have to improve its coordination with neighboring Afghan forces, they say.

“It’s still an unfinished job,” Hussain said. “Yes, they can control an area, but that control will remain tentative if we do not maintain a clear strategy for fighting terrorism and militancy.”

Haq Nawaz Khan in Peshawar contributed to this report.