Has Chinese President Xi Jinping managed to assert full civilian control over the People’s Liberation Army through purges of generals and admirals and other reform-related actions? China’s secretive and opaque political system makes it hard to get a clear picture. Yet recent developments suggest Xi is still struggling to keep the PLA in line.

Take the recent troop standoff with India that raised the specter of a Himalayan war, with China threatening reprisals if New Delhi did not unconditionally withdraw its forces from a small Bhutanese plateau that Beijing claims is Chinese territory “since ancient times.” After 10 weeks, the faceoff on the Doklam Plateau dramatically ended with both sides pulling back troops and equipment from the site on the same day, signaling that Beijing, not New Delhi, had blinked.

The mutual-withdrawal deal was struck just after Xi replaced the chief of the PLA’s Joint Staff Department. This topmost position — equivalent to the chairman of the U.S. Joint Chiefs of Staff — was created only last year as part of Xi’s military reforms to turn the PLA into a force “able to fight and win wars.” The Joint Staff Department is in charge of PLA’s operations, intelligence and training.

In mid-June, India’s close ally, the tiny Himalayan kingdom of Bhutan, discovered PLA crews working to build a road through Doklam, prompting New Delhi to dispatch troops and equipment to halt the construction of the road that was to overlook the trijunction where Tibet, Bhutan and the Indian state of Sikkim meet.

In seeking to use road construction to change the status quo in a disputed Himalayan territory, the PLA, in a strategic miscalculation, anticipated Bhutan’s diplomatic protest but not India’s rapid military intervention. With the attempted land grab also threatening Indian security, New Delhi was quick to turn Bhutan’s call for help into India’s own fight.

To be sure, this was not the first time the PLA’s belligerent actions in the Himalayas imposed diplomatic costs on China. A classic case was what happened when Xi went to India for a state visit in September 2014. Xi arrived on Indian Prime Minister Narendra Modi’s birthday with a strange gift for his host — a predawn Chinese military encroachment that day deep into India’s northern region of Ladakh. The encroachment, the worst in many years in terms of the number of intruding troops, overshadowed Xi’s visit.

It appeared bizarre that the military of an important power would seek to mar in this manner the visit of its own head of state to a key neighboring country.

Yet Chinese Premier Li Keqiang’s earlier visit to New Delhi in 2013 was similarly preceded by a 19-km PLA incursion into another part of Ladakh that lasted three weeks. The encroachment was seemingly intended to convey anger over India’s belated efforts to fortify its border defenses.

Such provocations might suggest that they are intentional, with the Chinese government in the know, thus reflecting a preference for blending soft and hard tactics. But it is also possible that the provocations — at least their timing and duration — underscore the continuing “disconnect between the military and the civilian leadership” in China that then-U.S. Defense Secretary Robert Gates warned about in 2011.

During his 2014 India trip, Xi appeared embarrassed by the accompanying PLA encroachment that cast a pall over his visit. He assured Modi that he would sort it out upon his return.

Soon after he returned, the Chinese defense ministry quoted Xi as telling a closed-door meeting with PLA commanders that “all PLA forces should follow the president’s instructions” and that the military must display “absolute loyalty and firm faith in the Communist Party, guarantee a smooth chain of command, and make sure all decisions from the central leadership are fully implemented.”

Just weeks later, Xi again asked for the PLA’s full loyalty to the party, telling a military-political conference in Fujian that “the Communist Party commands the gun.”

Recently Xi conveyed that same message yet again when he addressed a parade marking the 90th anniversary of the PLA’s creation on Aug. 1, 1927. Donning military fatigues, Xi exhorted members of his 2.3 million-strong armed forces to “unswervingly follow the absolute leadership of the party.”

Had civilian control of the PLA been working well, would Xi repeatedly be demanding “absolute loyalty” from the military or asking it to “follow his instructions”?

With its one-party dictatorship placing the Communist Party above the state, China does not have a national army; rather the party has an army. So the PLA has traditionally sworn fealty to the party, not the nation.

Under Xi’s two immediate predecessors, Hu Jintao and Jiang Zemin, the PLA gradually became stronger at the expense of the party. The military’s rising clout has troubled Xi because it hampers his ambition to become China’s most powerful leader since Mao Zedong. Xi’s present wife — folk singer Peng Liyuan — is actually a civilian member of the PLA, holding a rank equivalent to major general.

As part of his effort to reassert party control over the military and carry out defense reforms, Xi has used his anti-corruption campaign to ensnare a number of top PLA officers. He has also cut the size of the ground force and established a new command-and-control structure.

But just as a dog’s tail cannot be straightened, asserting full civilian control over a politically ascendant PLA is proving unachievable. After all, the party is ideologically bankrupt and morally adrift, and depends on the PLA to ensure domestic order and sustain its own political monopoly. The regime’s legitimacy increasingly relies on an appeal to nationalism. But the PLA, with its soaring budgets and expanding role to safeguard China’s overseas interests, sees itself as the ultimate arbiter of nationalism.

To make matters worse, Xi has made many enemies at home in his ruthless effort to concentrate power in himself, including through corruption purges. It is not known whether the PLA’s upper echelon respects him to the extent to be fully guided by his instructions.

The PLA and the government appeared to be on the same page during the Doklam standoff, with the Chinese foreign and defense ministries and other state organs keeping up a barrage of threats and vitriol against India. But no sooner had Xi fired the chief of the Joint Staff Department, Gen. Fang Fenghui, then a deal with India was clinched. This suggested that the topmost general was resisting ending the standoff.

Fang was fired just days after he hosted America’s highest-ranking military officer, Gen. Joseph Dunford, chairman of the Joint Chiefs of Staff. Fang was replaced by Gen.Li Zuocheng, considered a “war hero” for his combat role in the 1979 Chinese invasion of Vietnam, although China received a bloody nose from the more battle-hardened Vietnamese.

Xi’s military purges have been designed to consolidate his authority over the PLA and ensure that it does not blindside the government with actions or statements. But as Fang’s firing and other latest changes in the PLA leadership signal, Xi is still working to bring the military fully under his control.

More fundamentally, the PLA’s growing power is redolent of what happened in Imperial Japan, which rose dramatically as a world power in one generation after the 1868 Meiji Restoration. Boosted by war victories against Manchu-ruled China and czarist Russia, the Japanese military acquired political clout and gradually went on to dictate terms to the civilian government, as the 1931 Manchurian Incident first highlighted. This opened the path to aggression and conquest in Asia, with tragic consequences for Japan and the region.

In the past decade, the PLA’s increasing clout has led China to stake out a more muscular role. This includes resurrecting territorial and maritime disputes, asserting new sovereignty claims, and using construction activity to change the status quo. It won’t be long before the PLA rekindles Himalayan tensions with a major new encroachment.

China’s cut-throat internal politics and troublesome civil-military relations clearly have a bearing on its external policy. The risks of China’s rise as a praetorian state are real and carry major implications for neighboring countries.

Brahma Chellaney is a geostrategist.