But while the number of methadone programs has expanded since 2005, a shortage of clinics with adequate space and facilities meant that many people who might have benefited from the treatment were still missing out, said Dr. Rusdi Abdul Rashid, chief coordinator of the University of Malaya’s Center of Addiction Sciences , which runs the Ar-Rahman program.

When doctors first approached the mosque authorities and the government departments of Islamic Development, which must approve activities in Malaysian mosques, they encountered strong opposition. The authorities feared that methadone was forbidden in Islam, Dr. Rusdi said. But the doctors explained that methadone was different from other drugs because it is a medication and does not give patients a euphoric feeling.

“They agreed to allow us to pilot the program,” Dr. Rusdi said in an interview.

The program, which began in 2010, now has 50 patients whose ages range from 18 to 60. When they first join the program, patients must take the methadone under the watchful eye of pharmacists. After a couple of months and at least two consecutive urine tests that show they are negative for drugs, patients are allowed to take up to three doses home with them.

While the Malaysian methadone program marks the first one based in a mosque, the Islamic authorities have become involved in the fight against drugs in other countries, like China and Indonesia, where some Islamic organizations run rehabilitation centers.

Malaysia’s national Department of Islamic Development said it agreed to allow the methadone program at Ar-Rahman mosque after the National Fatwa Council granted permission for the use of methadone on the condition that it is taken under a doctor’s supervision.

“The use of methadone at Ar-Rahman mosque was permitted by religious authority because it is considered as a type of medicine that can be used as a treatment to drug addicts,” the department said in a statement.

“JAKIM believes this program can make the mosque as a social center for the community,” the department said, using the Malay acronym for its title.