Religious tradition runs deep in this ancient city in the heart of Indonesia.
The country's oldest Islamic university and one of its most influential Muslim charities are located here. In the city center, an ornate 18th century palace complex is home to one of the world's last surviving Muslim dynasties. Even healthcare here is often linked to faith; several of Yogyakarta's leading medical centers are operated by Islamic charities.
Yet religious hospitals and clinics in Indonesia, the world's most populous Muslim-majority country, do something that would be unthinkable at most religiously affiliated medical providers back in the U.S. They dispense contraceptives, including IUDs, birth control pills and condoms. Some even perform sterilizations.
In the U.S., many religious institutions are locked in an acrimonious fight with the federal government over birth control that is set to go before the Supreme Court next month. Elsewhere, by contrast, faith-based groups are increasingly linking arms with governments and health officials in a global effort to expand access to birth control.
This week, even Pope Francis connected family planning and health, saying contraceptives could be used to prevent pregnancies in places where the Zika virus, which has been linked to birth defects across Latin America, is spreading.
"Anything related to sex is controversial or uncomfortable, but with maternal and child mortality still so high in many parts of the world, people have become much more willing to work on this issue," said Mona Bormet, program director for Christian Connections for International Health, a leading U.S.-based consortium of Christian aid organizations. "The unmet need is just huge."
The health needs are driving a revolution worldwide in family planning.
World Vision, a multibillion-dollar evangelical Christian aid group based in Southern California, is now helping governments ensure dependable supplies of contraceptives.
In West Africa, Muslim, Catholic and Protestant leaders recently formed a partnership to exchange information on promoting family planning in their religious communities.
In Indonesia, where international faith-based organizations gathered in January ahead of a global family planning conference, a group of Muslim scholars has endorsed vasectomies as a form of birth control.
The family planning campaign comes as global health officials scramble to save the lives of more than 300,000 mothers who die annually from complications of pregnancy and childbirth.
Although maternal mortality rates have dropped by nearly half since 1990, deaths remain very high in many poor nations, driven in part by unintended and high-risk pregnancies. And progress has stagnated in some places.
In sub-Saharan Africa, for example, a mother is nearly 40 times more likely to die in childbirth than in the U.S., according to World Health Organization figures.
"If we were able to provide family planning services to all the women in the world who want them, we would prevent more than 50 million unintended pregnancies every year," said Dr. Babatunde Osotimehin, head of the U.N. Population Fund.
Widespread health coverage would also prevent 15 million unsafe abortions, Osotimehin said, noting unsafe procedures are a leading cause of death among pregnant women in many poor countries.
Enlisting religious groups in family planning campaigns has been a delicate task, as faith leaders have historically been wary of efforts to limit family size. Modern contraceptives, some of which are seen as inducing abortion, have been even more controversial.
As a result, some family planning advocates steered clear of local religious leaders. "People are afraid of stirring up opposition," said Katherine Marshall, senior fellow at Georgetown University's Berkley Center for Religion, Peace and World Affairs.
Even now, resistance from the Catholic Church in the Philippines and in Latin America has slowed family planning efforts in those places. And opposition from Muslim clerics in Iran, Pakistan and other Islamic countries remains a major barrier.
With progress slowing in many countries, advocates are now engaging churches, mosques and other faith-based institutions with messages that harmonize family planning with traditional religious teachings, including those that encourage procreation.
Both Islam and Christianity, for example, stress the importance of providing for children and ensuring their health and well-being, precepts that religious scholars cite in support of policies that allow families to plan how many children to have and how closely to space to space the births.
"There is this misperception that modern forms of contraceptives are inconsistent with faith," said Susan Otchere, who directs family planning programs for World Vision.
"We find that when we give people facts about how family planning relates to healthy timing and spacing of pregnancies and how that impacts the health of mothers and children in terms of nutrition, education, even family income ... then there is an 'aha' moment."
The effort is paying dividends.
In Senegal, for example, contraceptive use among women in several communities increased dramatically following an education campaign that relied heavily on Muslim religious leaders, according to the Gates Foundation, which helped support the initiative.
In East Africa, similar gains were recorded following an initiative by the Christian Health Assn. of Kenya, which represents hospitals run by Protestant churches.
And in Indonesia, leading Islamic organizations are frequently credited with helping deliver huge family planning gains in the '70s and '80s, during which time the country's birth rate dropped in half, making Indonesia an international model. At the time, leaders of those organizations issued fatwas, or religious rulings, stating that birth control was permissible.
Today, the country's universal health insurance system, created in 2014, provides Indonesians with coverage for all modern forms of contraception, including IUDs, birth control pills and hormone implants.
Outside Yogyakarta, on a stretch of highway surrounded by rice paddies, the Islamic Nur Hidayah medical clinic schedules vasectomies for men such as Istamar, a 52-year-old father of two, who was getting the procedure after his wife had an adverse reaction to an IUD.
"I came for her," Istamar explained as he waited on a wooden bench next to the check-in counter staffed by a pair of young women in traditional religious head scarves.
Indonesia's health reforms haven't eliminated all barriers to family planning, particularly for adolescents.
The insurance program only provides contraceptive coverage for married Indonesians, for example, reflecting persistent objections to premarital sex.
Not far from the Nur Hidayah clinic, the Al-Mahali Islamic boarding school offers students a regular class on reproductive health, featuring discussion of reproductive anatomy, sexually transmitted diseases and the risks of pregnancy. But contraception remains strictly off-limits.
And across Indonesia, abortion is illegal, except in emergencies.
Amin Abdullah, a leading Muslim scholar and family planning advocate who once headed the Islamic University of Indonesia in Yogyakarta, said reaching young, unmarried people with family planning must be a higher priority.
But, he cautioned, that will only be achieved if the effort involves faith leaders and links contraception with broader messages about health.
"It is impossible to ignore religion," Abdullah said. "This is the culture."
Reporting for this story was supported by a fellowship from the United Nations Foundation.
Follow @noamlevey on Twitter