Thousands of Muslims gathered at a mosque in northwestern China on Friday to protest its planned demolition in a rare public pushback to the government's efforts to rewrite how religions are practiced in the country.

A large crowd of Hui people, a Muslim ethnic minority, began congregating at the towering Grand Mosque in the town of Weizhou on Thursday, local Hui residents told The Associated Press by phone.

"People are in a lot of pain," said Ma Sengming, a 72-year-old man who was at the protest from Thursday morning until Friday afternoon. "Many people were crying. We can't understand why this is happening."

Ma said the group shouted "Protect faith in China!" and "Love the country, love the faith!"

The protest comes as faith groups that were largely tolerated in the past have seen their freedoms shrink as the government seeks to "Sinicize" religions by making the faithful prioritise allegiance to the officially atheist ruling Communist Party.

Islamic crescents and domes have been stripped from mosques, Christian churches have been shut down and Bibles seized, and Tibetan children have been moved from Buddhist temples to schools.