In some countries, though, clerics and worshipers defied restrictions or pressured governments to water down their orders, stoking fears that Ramadan could prompt a surge of infections.

Although public prayers were canceled in the capital of Indonesia, the world’s most populous Muslim-majority country, mosques were packed in the autonomous province of Aceh, where clerics ruled that prayers could continue.

At least 10,000 people attended Friday Prayer at the Baiturrahman Grand Mosque in Aceh, the local news media reported. Some said they were putting their safety in God’s hands — even as they wore face masks. “It is God who decides when we will die,” one masked devotee, Taufik Kelana, told the Reuters news agency. “But we will stay alert.”