As Xi Jinping has entrenched his hold on power in China, he has likened himself to a physician, eradicating the toxins of corruption and disloyalty that threaten the rule of the Communist Party. And his signature project for over a decade has been bringing to heel the once extravagantly corrupt military leadership.

But recent upheavals at high levels of the People’s Liberation Army forces suggest that Mr. Xi’s cure has not endured. Last week, he abruptly replaced two top generals in the Rocket Force, an unexplained shake-up that suggests suspicions of graft or other misconduct in the sensitive arm of the military that manages conventional and nuclear missiles.

“Obviously, something has gone wrong in the system, which is probably related to discipline and corruption,” said Andrew N.D. Yang, an expert on the Chinese military who was formerly a senior Taiwanese defense official. “It’s like a virus in the system that has come back. It’s a deep-rooted problem, and it has survived in the system.”

A scandal involving the top brass of the armed forces would be a setback for Mr. Xi, who has taken pride in turning the 98 million-strong Communist Party and the Chinese military into unquestioning enforcers of his rule. Days before the generals were ousted, Mr. Xi removed the foreign minister, Qin Gang, another troublesome dismissal for Mr. Xi, who had elevated Mr. Qin as a trusted enforcer of his policies.

The signs of misconduct are likely to reinforce Mr. Xi’s conviction that China’s officials can be kept from straying only with intense scrutiny and pressure from above. That strategy includes subjecting cadres to constant inspections by party investigators; campaigns to instill loyalty to the Communist Party and to Mr. Xi; and to dismissals and arrests.

In Mr. Xi’s view, “you never get to the point where the danger recedes,” said Joseph Torigian, an assistant professor at American University in Washington who studies elite politics in China. “Even when you have an absolutely dominant leader, that doesn’t mean you don’t have churn in the system.”

When Mr. Xi came to power in 2012, he moved urgently to clean out corruption and lax discipline in the People’s Liberation Army, subduing potential rivals and centralizing power around himself — an overhaul that set an example for how he has transformed China as a whole.

In 2014, Mr. Xi gathered hundreds of senior officers at the same site where Mao Zedong had extended his sway over the revolutionary Red Army. Mr. Xi warned them that the military was rotting from within. Investigators had exposed Xu Caihou, a former vice chairman of the Central Military Commission — the party’s arm for controlling the armed forces — who had amassed a fortune from bribery; a general who hoarded jewels and cash in his homes and also consulted fortune tellers; officers buying and selling promotions; and some even selling secret information.

Mr. Xi was also warning of deepening rivalry with the United States, and he told the generals that the internal decay could be disastrous. “What starts as decadence will slide toward destruction,” he said, citing an ancient Chinese aphorism.

In the years that followed, Mr. Xi reorganized the People’s Liberation Army, bulldozing past potential opposition. Dozens of senior officers were convicted of corruption, and the buying and selling of promotions, once common, receded. Mr. Xi instituted new rules to cement his powers as the chairman of the Central Military Commission and commander in chief.

Today, virtually all members of China’s military elite owe their rise to Mr. Xi, giving him a firm edifice of power, said Daniel C. Mattingly, a political scientist at Yale University who analyzed the career paths of 1,200 officers in the People’s Liberation Army, or P.L.A. Mr. Xi’s second-in-command is Gen. Zhang Youxia, the son of a general who served alongside Mr. Xi’s father in the revolution, and a high proportion of other senior officers have a career link to Mr. Xi, some going back to his time as a local official, Mr. Mattingly said.

“The Chinese Communist Party’s civilian norms and institutions already make a leadership challenge really hard,” he said. “The fact that the P.L.A. is full of Xi’s people makes it much, much harder.”

The People’s Liberation Army Rocket Force has stood out as a product of Mr. Xi’s support. He created the force in late 2015, elevating it from the former missile corps. He has “invested a lot of time and resources, and policy support,” said Brendan Mulvaney, the director of the China Aerospace Studies Institute at the U.S. Air University. The Rocket Force oversees “the largest and most diverse” missile program in the world, he said. Its inventory includes an array of missiles designed to carry nearly all of China’s 400 or more nuclear warheads.

“Xi talks about the P.L.A. Rocket Force as being central to future conflicts,” Mr. Mulvaney said. “So this much shake-up had to have a significant reason behind it.”

The top commander of the Rocket Force who fell from grace, General Li Yuchao, had been elevated to that post by Mr. Xi only early last year. General Li, along with the political commissar of the force, Xu Zhongbo, and another deputy, Liu Guangbin, have vanished from public view.

Most experts believe that General Li and possibly other senior officers may be accused of siphoning some of the enormous spending going into the fast-expanding force, though other allegations of misconduct may also play a role.

“Within the Chinese military, always follow the money. The corruption always goes with whatever it is that they’re building,” said Christopher K. Johnson, the president of the China Strategies Group and a former Central Intelligence Agency analyst of Chinese politics. “Where’s the money right now? It’s in the massive build program for their nuclear expansion.”

But Mr. Xi has warned that economic corruption and political disloyalty are intertwined. His predecessor, Hu Jintao, seemed to wield weak authority over the military top brass, and the leader before Mr. Hu, Jiang Zemin, struggled with an insubordinate commander. To defend his own authority, Mr. Xi appears willing to purge even the generals he has promoted.

In 2017, two commanders who had been elevated by Mr. Xi to the Central Military Commission— Zhang Yang and Fang Fenghui — were ousted over corruption allegations. General Zhang took his own life, and General Fang was imprisoned.

Now demands for the People’s Liberation Army to demonstrate its loyalty may redouble. Days before Mr. Xi installed the two new leaders of the Rocket Force, he told troops in southwest China that the campaign against lax discipline and corruption must “go deeper and deeper.” The People’s Liberation Army has also recently rolled out a new study campaign to instill loyalty to him. But with so much at stake in China’s nuclear weapons programs, Mr. Xi may keep details about the fallen rocket force officers secret.

“Whatever is happening with the former leadership of the P.L.A., Rocket Force will remain mostly opaque to the outside world,” said David Finkelstein, the vice president for China and Indo-Pacific security affairs at CNA, an institute in Arlington, Va. “Either way, the message to the force will be: ‘No one, however high in rank, is beyond the long reach of the party when lapses in discipline have occurred.’”

Amy Chang Chien contributed reporting.