“Losing the Philippi Horticultural Area to development would be catastrophic,” says farmer Nazeer Sonday who has been fighting to protect this farmland in the heart of Cape Town for nearly a decade.“The area is key to the city’s climate resilience and resolution of its food crisis.”

The coming months are critical. Last week, a court battle began which Sonday fears may determine not only his own future, but that of the most fertile agricultural land in South Africa.

60% of Cape Town households cannot afford nutritionally balanced meals. One-in-four South African children are classified as stunted

An hour’s drive around Table Mountain from the centre of Cape Town, the PHA is surrounded by the densely populated Cape Flats townships of Mitchell’s Plain, Grassy Park and Athlone – areas infamous for poverty and gang violence. Yet, cooled by sea breezes from nearby False Bay which help make up to five crop cycles a year possible, the farmland produces around 200,000 tonnes of vegetables a year, mostly carrots, cabbages and squashes. Its 50 farms supply up to 30% of vegetables consumed in the city.

The underground aquifer on which the PHA sits is crucial too, providing irrigation and drinking water even during times of severe drought. Last year, as the city neared “day zero”, the Cape Flats Aquifer remained a key water source.

But despite being farmed for more than 130 years, campaigners fear the city’s vegetable basket is under threat. Last Tuesday the PHA Food and Farming Campaign and Sonday, its chairman, brought a case against the City of Cape Town and the provincial government for Local Development, Environmental Affairs and Development Planning.

Aerial view of the Philippi Horticultural Area, with Table Mountain on the horizon. Photograph: Grant Duncan Smith/Getty Images/Gallo Images

The campaign is contesting decisions that allowed the rezoning and environmental authorisation of an area of the PHA for development. The land in question belongs to Oakland City Development Company and the city claims it is not part of the PHA. Lawyers for the city argued in court that the development would provide homes for 15,000 families and schools for their children, and that the aquifer would be better protected by stormwater management if it went ahead. They say the city supports the protection of the core agricultural area of the PHA, but that this particular piece of land falls outside that, and isn’t used for farming.

The larger commercial farmers are less concerned by the plans, with some believing urban development might even help tackle crime in the area – in their view a far bigger problem.

Q&A What is South African cities week? Show Twenty-five years after the fall of the brutal apartheid regime, South Africa's cities remain hugely divided, both economically and racially. This week Guardian Cities explores the incredible changes taking place, the challenges faced and the projects that bring hope. Africa correspondent Jason Burke reports from the Flats, where violence and death are endemic just miles from Cape Town's spectacular beaches and trendy cafes. Author Niq Mhlongo pens a love letter to the "other Soweto", one that visitors to gentrified Vilakazi Street never see. We hear from Port Elizabeth, where one architect is using recycled materials to transform his city, and Durban, where a surf school is changing the lives of vulnerable children. We explore the deadly underground world of zama zama gold miners operating illegally under the city of Johannesburg, visit the Afrikaner-only town of Orania and publish an extraordinary photo essay by Magnum nominee Lindokuhle Sobekwa, who documents life in a formerly white-dominated area where his mother once worked as a domestic helper. Nick Van Mead

Campaigners, though, who are mainly smaller-scale farmers, say the PHA farmland has already shrunk from 3,000 hectares in the 1960s to 1,884 hectares now. Urban sprawl, illegal dumping, illicit sand mining and land speculation threaten to reduce the land dedicated to agriculture even further, they say.

Should the whole area be rezoned, and agriculture disappear from the farmlands, up to 6,000 workers will lose their jobs and more than 30,000 livelihoods dependent on the PHA will be negatively affected, adds Sonday.

In a city with what an African Centre for Cities report described as “grotesque levels of food insecurity” decisions about the farmland’s future are even more critical. An estimated 20% of the PHA yield is sold to informal traders including spaza shops, hawkers and street vendors who sell to low income consumers in and around the surrounding townships.

The erosion of the PHA from 1967 to 2017. Photograph: Indego Consulting

In nearby Nyanga street vendors are out in force with displays of carrots and brinjals on blankets and wooden tables; live chickens squawking their objections; and barbecued meats on open grills. People and chickens dodge the kombi taxis and cars. Most of the vegetables on sale here come from the PHA.

However, about 80 to 90% of the produce from the PHA is bought by supermarket chains which sell it on at prices poorer Cape Town residents cannot afford.

According to Jane Battersby, a researcher at the African Centre for Cities, around 80% of households in low income areas of the city are food insecure. This generally means limited dietary diversity with an emphasis on refined carbs, unhealthy fats and sugar-filled foods and drinks, as opposed to high-quality protein and varied fresh fruit and vegetables. In fact, 60% of all Cape Town households cannot afford nutritionally balanced meals. Shockingly, one-in-four South African children are classified as stunted because of poor nutrition, and the problem is worsening, especially among younger children.

The centre’s Hungry Cities Partnership report highlighted “extreme inequality in levels of food security” in Cape Town. It is overwhelmingly a problem affecting black and coloured populations of the city, says co-author Gareth Haysom.

A legacy of apartheid’s spatial segregation, in which the races were separated geographically and non-whites forcibly removed to live far from the centre, is that Cape Town’s poor routinely have to commute several hours to work. This gives scant opportunity to purchase and prepare food. The cost of cooking fuel – whether electricity, gas or paraffin – also determines what people eat. Ready prepared foods, which are often highly processed, are popular.

A lack of refrigeration is another problem. In Jim Se Bos, an informal settlement inside the PHA where roughly half the inhabitants are farm workers, many displaced years ago from farms where their families had lived for generations, electricity was only connected this May after a 15-year fight.

The PHA is not the only place where farming takes place in Cape Town. A 2018 study estimates there are 4,000 gardens and 100 community gardens in the Cape Flats, which are mostly located in urban areas outside the PHA.

‘Young people don’t want to get dirty working the land’ … workers at Nyanga Garden Centre in Cape Town Photograph: Mary Bradley

But if you’re working and commuting upwards of 12 hours a day, would you have time to tend your own garden plot with fresh vegetables? Unlikely, says Tracy Ledger, head of research at the University of the Witwatersrand’s Public Affairs Research Institute.

Unsurprisingly, the farmers I meet in the urban gardens of Khayelitsha and Nyanga are retired or unemployed and overwhelmingly female. Farming does not appear to be attractive or economically viable for men and young people in these townships. Some point to a social stigma about tilling the soil among the many township residents who hail from the rural Eastern Cape. “Young people don’t want to get dirty working the land,” says Xoliswa Magutywa, a farmer and founding member of the Moya We Khaya Gardening Cooperative.

After two days in court, judgement was reserved in the PHA case. There is no indication of when it will be delivered but campaigners have vowed to keep fighting.

Sonday believes that if this case is lost and the development goes ahead, others will follow. If costs are awarded against him he will lose his farm.

“This particular court case is precedent-setting,” Sonday told news organisation Groundup. “If we lose, we will lose the rest of the Philippi Horticultural Area and the Cape Flats Aquifer. Everyone is affected by what happens to the PHA.”

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. Share your views here on how South African cities have changed in the last 25 years