Pope Francis and Chinese President Xi Jinping are, in many ways, worlds apart. One is the spiritual leader of 1.2 billion Catholics (over 40 percent of whom reside in Latin America) and the other presides over 1.4 billion Chinese. Pope Francis is a religious leader and Xi Jinping is a political one.

But what distinguishes one from the other is far more complex than religion and politics. When Pope Francis visited Cuba earlier this month and ignored dissidents opposed to the Castro regime, he made a blatantly political decision. When the pontiff urged members of the U.S. Congress to change their attitude about immigration, economic inequality, and climate change, he also acted like a political leader. Likewise, when Xi Jinping, who just concluded a less-publicized visit to the United States as well, urges his people to pursue the “Chinese Dream” or to behave according to “Chinese values,” he is trying to add some spiritual hue to his politics and leadership.

In fact, the similarities between the two leaders are as instructive as the differences. Both are in charge of immense societies with ancient cultures that are struggling to respond to modern challenges, from changing mores regarding reproductive rights to the use of social media. Both are confronting these contemporary realities at a time when the traditional responses of their respective institutions—authority, infallibility, secrecy—have lost effectiveness. And perhaps most surprisingly, both are tackling these challenges in similar ways. Here are just three examples.

1. Taming powerful bureaucracies

In China, Xi Jinping is seeking to reform the Communist Party machinery. In the Vatican, Pope Francis is striving to do the same with the curia—the bureaucracy that runs the Roman Catholic Church and has enormous influence in shaping Catholicism. These efforts pit both leaders against groups and individuals whose beliefs, commitment to traditions, and desire to retain power or defend vested interests create enormous obstacles to change.

Among other things, the pope has denounced the curia’s members for feeling “immortal, immune, and indispensable”; suffering from “mental and spiritual petrification,” “spiritual Alzheimer’s,” and “existential schizophrenia”; indulging in gossip and slander; and being overly concerned with hierarchies and indifferent to anyone but themselves.

Xi is similarly harsh in his criticism of the sluggishness and dysfunction that plague Chinese bureaucrats, who he claims are more concerned with lining their pockets—and those of their family and friends—than serving the nation.

2. Taming official corruption and materialism

Both leaders have chosen to make the fight against corruption one of their signature initiatives.

Francis is trying to clean up the corrupt Vatican Bank and continuing to confront sexual-abuse scandals involving Catholic priests. In 2013, he sent a strong message by suspending a German bishop known for his opulent lifestyle. Among the “sicknesses” that plague the curia, Francis includes the accumulation of “material goods” and the search for “worldly profit and showing off.”

Xi has arguably been even more aggressive in his campaign against venality: More than 414,000 Communist Party officials have been disciplined for corruption and another 200,000-plus have been prosecuted for the offense. Several have been executed, and the Chinese government is actively seeking to repatriate hundreds of Chinese public servants who have fled the country to avoid charges.

3. Taming fragmentation and schismatic pressures

The Catholic Church and the Chinese government are each attempting to bridge deep and consequential internal divisions borne of several factors, including economic and social transformations, the impact of disruptive technologies, and a revolution of expectations and aspirations among a better-informed and more politically active and empowered populace.

The Vatican, for instance, is currently contending with fierce global competition among Christian denominations to retain and attract souls. In Latin America, the share of Catholics has declined by 23 percentage points since 1970; in the United States, for every new Catholic six abandon the Church. Many join evangelical Protestant churches.

China may be an efficient police state adroit at silencing critics, but the government still faces frequent street protests and calls to reform the Chinese model of governance. Defending the model was easier when the Chinese economy was consistently growing at a rapid pace, generating jobs, increasing workers’ incomes, and pulling millions out of poverty. But when such economic growth ceases to be a certainty—much as is happening now—the social compact that has allowed the Communist Party to rule without much opposition will begin to erode.

In other words, Pope Francis and Xi Jinping are both engaged in monumental efforts to adapt to modern dynamics without losing the very legitimacy that enables both leaders to preside over hundreds of millions of people. The organizations they lead are hulking, hierarchical, and slow—and they are being forced to perform in a world where speed and agility are essential for success, and where networks of empowered individuals often trump centralized bureaucracies. The outcome of their efforts is not preordained, and the consequences will extend far beyond Catholics or Chinese citizens.