BEIJING (AP) — China's president warned in a key policy speech that religions must be independent from foreign influence, as the government asks domestic religious groups to pledge loyalty to the state.

Hours later, Pope Francis urged Catholics in China to be "united to the rock" of the church in Rome, although it was unclear whether his comments were linked to the speech earlier Wednesday by Chinese President Xi Jinping.

China is ruled by the officially atheist Communist Party, and Beijing attempts to control a variety of religions and their spread.

"We must manage religious affairs in accordance with the law and adhere to the principle of independence to run religious groups on our own accord," Xi said at a high-level party meeting that sought to unite non-Communist Party groups and individuals. His comments were widely reported in state media.

"Active efforts should be made to incorporate religions into socialist society," Xi said, adding that the party's religious work should be about winning over the hearts and minds of the public for the party.

As part of its religious policy since the 1990s, the government believes that hostile foreign forces can use religions to infiltrate Chinese society by winning over the population and subverting party rule. It has banned foreign missionary work, refused to acknowledge any appointment by foreign religious entities such as the Vatican, and declared any unregistered religious groups illegal.

Formal relations with the Vatican already were severed back in 1951, and worship by Catholics is officially allowed only in state-authorized churches outside the pope's authority. In 2007, Pope Benedict XVI sent a letter to Chinese faithful urging them to unite under his authority.

On Wednesday in Rome, Francis urged Catholics in China "to live spiritually united to the rock of Peter upon whom the Church is built" during his general audience ahead of an important feast day May 24 for Chinese Catholics at the shrine of Sheshan in Shanghai.

In the western Chinese regions of Xinjiang and Tibet, the government says foreign forces are using Islam and Tibetan Buddhism to incite local people to defy Chinese rule.

Still, religions have spread quickly in the country, which is suffering a crisis in beliefs as people largely abandon communist values.

Since early 2014, the eastern Chinese province of Zhejiang has forcibly removed crosses from more than 400 Christian churches in an apparent effort to reduce the rapidly growing religion's visibility.

However, the government has been vague about what constitutes foreign forces and whether the term refers to foreign individuals, foreign non-governmental groups, foreign cultural traditions or foreign governments, said Yang Fenggang, a scholar of Chinese religions at Purdue University.

Such a policy can also be difficult to carry out in an age of globalization and at a time when China wants to promote its own culture outside China, he said.

"How can you influence the foreign but not be influenced by the foreign?" Yang wrote in an email.