Since coming to power, Philippine President Rodrigo Duterte has tirelessly sought to win over hearts and minds of the country's security forces. Unlike any of his recent predecessors, the Philippine president has lavished them with praise and increased their benefits, salaries, and bonuses.

But the powerful Armed Forces of the Philippines (AFP) has, so far, stood its ground, maintaining a broadly professional relationship with the commander-in-chief.

The AFP has protected its good name by studiously avoiding any involvement in Duterte's controversial war on drugs and emerged as the "steady state," a bastion of predictable conservatism amid Duterte's disruptive politics. It has, quite ironically, acted as a guardian of Philippine democracy. Meanwhile, in foreign affairs, it has done its best to check the president's push to switch from close ties to the U.S. to a China-leaning policy.

Things came to head in early September when the military politely refused to follow Duterte's order to implement the arrest, without a warrant, of his chief critic, Senator Antonio Trillanes, on old charges of plotting coups against a previous president, Gloria Arroyo.

Almost a month later, on Sept. 25, a regional court issued a warrant of arrest for Trillanes, who surrendered to authorities voluntarily and is set to challenge charges against him in court after posting bail.

But the AFP's refusal to short-circuit the judicial process protected its institutional integrity and exposed the limits of Duterte's arbitrary power in the face of the military.

No Filipino leader has been so attentive to winning over the men and women in uniform since the days of Ferdinand Marcos dictatorship. In his first three months in office, Duterte visited as many as 14 military camps to rally support and build trust with top commanders.

The charm offensive reflects Duterte's instinct for survival. In the past three decades, the AFP ended the reign of Marcos (1986) and Joseph Estrada (2001) when it withdrew institutional support from the presidency amid nationwide opposition protests, dubbed as "People Power Revolutions."

Duterte is also aware of the fact that the military suspiciously views his perceived coziness with communist rebels, especially during his mayoral days in Davao, and, more recently, with China.

The AFP has historically treated communist rebels and Beijing as the country's leading domestic and external threats.

While Duterte has described Beijing as a friend and development partner, the AFP has regularly leaked information to the media about China's militarization of Philippine-claimed land features in the South China Sea.

Despite Duterte's diplomatic spats with Western allies, the AFP has successfully maintained robust defense ties with the U.S. and Australia, which, for example, played a key role during the liberation of Malawi from Islamist militants last year. They provided special forces training, high-grade weapons and real-time intelligence.

The AFP has also stepped up its maritime security cooperation with Western allies in the South China Sea to check China. As a result, Duterte has struggled to significantly downgrade strategic ties with Washington in favor of Beijing, which he views as a natural ally.

Strategically, the Philippine president also knows that personal control over the security forces is a key to power, especially if, as his critics allege, he seeks to establish an autocratic regime.

Eager to impress the security forces, Duterte is set to increase the salary of entry-level police and soldiers by 100%, while ranked officers will enjoy a 72% salary boost next year. He is also adding 15,000 new posts in the law enforcement agencies.

Duterte's personal charm offensive has worked wonders with the police, turning into a loyal servant of his scorched-earth anti-crime campaign.

The Philippines National Police force's backing was crucial to Duterte's almost-arbitrary exercise of power in his early months in office, when he openly defied courts and legislator in cracking down on suspected drug dealers.

For critics, the PNP has effectively turned into Duterte's personal army. The same, however, can't be said about the AFP, which repeatedly refused to get involved in the drugs war, partly out of concern for jeopardizing its professionalism as well large-scale military aid from Washington.

The military establishment has also repeatedly questioned Duterte's calls for nationwide martial law and installation of a so-called "revolutionary government." This resistance to Duterte's authoritarian lurch reached a crescendo when it refused to forcibly arrest Trillanes, a former navy officer, who was previously imprisoned for multiple coup attempts against the Arroyo administration.

Trillanes was allowed to enter politics in January 2011, when he received amnesty from the Benigno Aquino administration. In the past year, he has emerged as a leading critic of Duterte, who, in response, ordered his arrest on Aug. 31 by unilaterally nullifying Trillanes' amnesty.

But the military refused to follow the unconstitutional order and instead asked the courts to issue a warrant, as has now happened. Defense Secretary Delfin Lorenzana questioned Duterte's order by stating "anything that doesn't follow due process should be rectified."

The AFP's pushback infuriated the president. In response, he lashed out at the men in barracks in a "national address" on Sept. 11, accusing the military of not respecting his democratic mandate and taunting the armed forces to "go to [Trillanes] and stage a mutiny or revolution or whatever."

At this point, talk of a coup against Duterte remain unsubstantiated. The president remains popular, but the AFP made it clear that they are not his personal army and are willing to check any blatant exercise of arbitrary power.

Philippine democracy remains fragile, so it is crucial for the defense establishment to maintain its institutional independence and professionalism, while leveraging its influence to constrain Duterte's worst authoritarian instincts.

So far, the military has fortunately acted as a check on the presidency only in areas which directly fall within its jurisdiction, including defense policy. Thankfully, unlike in nearby Thailand, it has shown little appetite for taking over power.

But civilian political forces, especially the parliamentary opposition, should not rely so much on the army to protect the country's democratic institutions. Ultimately, in a democracy, the military cannot be a substitute for effective civilian restraints on the abuse of power.

Richard Heydarian is a Manila-based academic, columnist and author; his latest book is "The Rise of Duterte: A Populist Revolt Against Elite Democracy."