Philippine President Rodrigo Duterte has reversed his decision to scrap a major defense pact with the U.S., salvaging a cornerstone of the two countries’ military alliance and reinforcing efforts to counterbalance an increasingly assertive China.

The fate of the Visiting Forces Agreement had been in limbo since the Philippines notified the U.S. in February 2020 that it would withdraw from the pact, part of Mr. Duterte’s efforts to distance Manila from Washington in favor of Beijing. His reversal, however, underscores the resilience of a U.S.-Philippines relationship that has weathered decades of shifting political tides.

“The president decided to recall or retract the termination letter,” Philippine Defense Secretary Delfin Lorenzana said Friday at a joint press briefing with U.S. counterpart Llyod Austin during Mr. Austin’s first visit to the country as the Pentagon chief. “We are back on track.”

U.S. Defense Secretary Lloyd Austin and Philippines Defense Secretary Delfin Lorenzana met at Camp Aguinaldo in Quezon City Friday.

U.S. Defense Secretary Lloyd Austin and Philippines Defense Secretary Delfin Lorenzana met at Camp Aguinaldo in Quezon City Friday.

Photo: Rolex dela Pena/Associated Press

Since it was signed in 1998, the agreement has allowed U.S. troops and equipment such as ships and aircraft easy access to the Southeast Asian archipelago. It facilitated hundreds of annual engagements, including the training of Filipino troops, port calls and joint exercises. Mr. Austin said the pact “enables us to respond quickly and seamlessly to disasters or crises.”

The U.S. and the Philippines are also bound by a 1951 Mutual Defense Treaty, which obliges both parties to respond to attacks against the other. Military analysts say the Visiting Forces Agreement would be critical to facilitating such a response, as it allows for unimpeded movement of troops and hardware.

Mr. Duterte’s withdrawal was partly a response to a Senate resolution in January 2020 condemning alleged extrajudicial killings as part of an antidrug campaign in the Philippines, calling for U.S. sanctions against some Philippine officials. Human-rights groups say more than 12,000 people have been killed in antidrug operations since Mr. Duterte took office.

But untangling U.S. and Philippine military ties proved easier said than done. Under the terms of the agreement, it remained in force for 180 days after either party notified the other of its wish to terminate. During that time, the Philippines had several confrontations with Chinese vessels in the South China Sea, raising the threat of a more serious standoff.

Rodrigo Duterte is limited to one presidential term under the Philippine constitution but could aim to run for vice president.

Rodrigo Duterte is limited to one presidential term under the Philippine constitution but could aim to run for vice president.

Photo: lisa marie david/pool/Shutterstock

Allowing the pact to expire could have brought both political and security risks, while the deepening Covid-19 crisis added humanitarian concerns. Mr. Duterte extended its expiration date three times—first in June 2020, again in November 2020 after President Biden’s election victory, and in June 2021 amid negotiations with the Biden administration.

Collin Koh, a research fellow at the S. Rajaratnam School of International Studies in Singapore, said motivations for keeping the agreement intact may have been twofold: It serves as insurance against escalating Chinese aggression and reduces political risk during elections next year. Mr. Duterte is limited to one term under the country’s constitution, though he hasn’t ruled out a run for the vice-presidency. Exiting the agreement could cost his party support and make it difficult for him to pair with a running mate.

Despite his rhetoric, Mr. Duterte “still keeps the American card in his pocket,” Mr. Koh said. “It’s quite clear that he’s aware the U.S. is useful from a broader strategic perspective.”

“I don’t think this will be forgotten. It will leave a scar,” he said. “It serves as a good reminder to both sides that these military and strategic ties should not be taken for granted.”

Write to Feliz Solomon at feliz.solomon@wsj.com