At Karet Bivak cemetery in Jakarta, the neat rows of headstones extend as far as the eye can see, seeming to sprout into skyscrapers at the horizon.

Driving his scooter through after Friday prayers, a friendly Muslim man wearing white robes and a taqiyah cap seems at peace with his fate. “This is my future home,” he says, leaning on the handlebars and indicating the graves. “Your home, my home – everybody’s home.”

No longer. Set over 16 hectares of former rubber plantation, Karet Bivak is Jakarta’s second-largest cemetery – and, like an increasing number across the city, it is full. Authorities froze new plots in November 2017 to prevent overcrowding. For now and the foreseeable future, the only way to be buried here is for your body to be stacked on top of another one.

Karet Bivak cemetery, Jakarta. Photograph: Elle Hunt

Up to six people, typically from the same family, are being buried in a space originally designated for one. There are now some 100,000 bodies in 48,400-odd plots.

It is a stopgap solution to a shortage of burial land in a city where overcrowding above ground is increasingly extending below it. Of 84 public cemeteries, a quarter have stopped licensing new plots, limiting burials to those with written permission to join an existing one. Meanwhile, the number of cemeteries stacking bodies, known as makam tumpang – “overlapping graves” – was reported as 16 in August, and is now confirmed at 20.

Bodies can be stacked alongside or on top of each other, according to municipal policy, with a minimum of one metre between them. Plots must also be at least three years old before another body can be added, by which point only a skeleton remains.

It is very hard to get land for a cemetery, or even development of infrastructure ... people don't want to sell their land Rangi Faridha

The head of Karet Bivak, Saiman (who, like many Indonesians, goes by one name), says stacking is no issue for the dead: problems only arise among the living. There have been graveside conflicts, he says, when one of the bereaved has realised too late that the deceased is joining an occupied plot.

Family rifts have also been weaponised by the requirement for written permission from the licence holder. Ricky Putra, head of the funeral service unit at the Jakarta Forestry Agency, says one woman refused her late ex-husband use of the family plot because he had remarried. In another case, a man wanted to be buried on top of his uncle but his cousin blocked him due to jealousy.

Since the overcrowding issue emerged about three years ago, Putra says, the department has worked hard to educate the public about its stacking solution. As well as articles in press and social media, Karet Bivak hung banners in the lead-up to Ramadan – the busiest time of year for Muslim cemeteries, when thousands make a pilgrimage to loved ones’ graves.

A couple read the Qur’an at a relative’s grave. Photograph: Beawiharta Beawiharta/Reuters

Jakarta’s high population density means most public cemeteries are boxed in by buildings, with regulations further preventing their expansion. In south Jakarta, the Kalibata Heroes cemetery is converting its gardens into graves, to expand its capacity by 900.

“It is very hard to get land for a cemetery, or even development of infrastructure,” says Rangi Faridha, an architect on the city planning and development board. “There are many factors, but the biggest one is that people don’t want to sell their land.”

Long before they started stacking, cemeteries also dug up “expired” graves, ones where licences had been allowed to lapse. Approximately 20,000 plots at Karet Bivak were freed up in this way – but as with stacking, this policy can only do so much to meet demand.

The growing number of public cemeteries reaching capacity is a concern but not a crisis, says Putra in his office, the files behind him piled almost to the ceiling as if to undermine his claims. He says the city still has 200 hectares (494 acres) of land in reserve for cemeteries, and pulls up pictures on his phone of a 20-hectare area under development in north Jakarta – a stretch of swampland that is slated to open in 2021.

In Jakarta, the local people live close to cemeteries, so they really have a social value. People just hang out there Dr Mohamad Reza Mohamed Afla

But with 80 to 100 bodies being received at public cemeteries every day, the issue continues to be pressing, particularly for poorer Jakartans. Five of the 20 full cemeteries are in east Jakarta, where the city’s poverty rate is highest. Public cemeteries typically charge about 100,000 Indonesian rupiah (£6) for burial in a new plot, and then a smaller license fee every three years; for perspective, the poverty line is set at 400,000 rupiah per month.

Most poorer people seek to send their dead to the one closest to their home, in the interests of both convenience of visits and keeping down costs – but if your closest public cemetery is full you must incur the extra costs yourself of travelling further afield. Even ambulances charge a fee.

Meanwhile, Saiman says, private cemeteries are popping up for those who can afford them, including “luxury parks” such as San Diego Hills in Karawang, West Java, where a burial – including coffin, embalming, certification and licence – can cost more than 26m rupiah.

San Diego Hills luxury cemetery in Karawang. Photograph: Putu Sayoga/Getty Images

At Karet Bivak, Saiman says, it costs between 10,000 and 25,000 rupiah to license a plot for three years, but for extra care there are hundreds of informal caretakers – often below the poverty line themselves – who make their living providing grave maintenance as “freelancers”, and in many cases live in the cemetery itself. In east Jakarta, the predominantly Chinese Kebon Nanas cemetery is home to as many as 200 people.

With its active service economy, signposted subdivisions and food carts and stalls at each gate, the cemetery is like a central neighbourhood. For many residents it is also their most accessible open green space.

Jakarta has less than 5% green space, forcing people in search of respite from the pace and pollution of the city into cemeteries; last year a party in an east Jakarta graveyard, complete with sound system and marquees, prompted a rebuke from the city administration.

Building more cemeteries could be a huge opportunity for the city, says Dr Mohamad Reza Mohamed Afla, a senior lecturer at Universiti Sains Malaysia in Penang who specialises in burial land management. Cities across south-east Asia are facing the same issue of overcrowding – in Singapore, stacking has been mandated for many years, while Kuala Lumpur is considering it – but he says Jakarta is at an advantage in that many of its public cemeteries are centrally located and residents and authorities already recognise their value as public space.

“In Jakarta, the local people live close to them, so they really have a social value,” he says. “People just hang out there – in Kuala Lumpur, we don’t do that.”

He argues that cemeteries also create jobs and help reduce the impact of heat, adding that a truly liveable city is one that ensures its residents’ wellbeing into the afterlife.

Follow Guardian Cities on Twitter, Facebook and Instagram to join the discussion, catch up on our best stories or sign up for our weekly newsletter