The drive to build more toilets in India has been given an unusual twist with a Rajasthan judge granting a woman a divorce because her husband’s failure to provide her with one amounted to cruelty.

Sangeeta Mali, 23, told the court in Bhilwara district that her husband, Chotu Lal Mali, had agreed to build her a toilet when they married in 2011, but never did. Mali told the judge that she was ashamed of having to defecate in the fields around her home in Pur village with no privacy or comfort.

“He kept saying he would build it but it was just talk. In the end, he refused point blank. My in-laws also refused. Every day was agony – waiting for it to get dark so that there was no one around who could see me, forcing me to hold on even though my bladder was bursting. I couldn’t live with the stress any more,” she told the Guardian.

For the past two years, Mali has had to use the toilet at her mother’s home in another village. At the end of 2015, with no toilet in sight, she decided to file for divorce.

Mali’s story has made the front pages of Indian newspapers. The judgment given on Friday by Justice Rajendra Kumar Sharma has been widely quoted for its strongly worded views.

Sharma said the fact that women have to defecate in the open amounted to “mental torture” and was a disgrace in the 21st century. “Has it ever pained us that our mothers and sisters have to go to defecate in the open? Women in villages have to wait for dark to venture out in order to relieve [themselves] and as a result have to bear … physical pain,” he said.

“It is an irony that people who spend a lot of money on alcohol, tobacco and mobile phones don’t have toilets in their homes.”

Mali’s lawyer, Rajesh Sharma, said he was pleased with the coverage of the case. “We are very backward compared with other countries. If we want our women to live with dignity, and if we want our country to be clean and great again, we have to build toilets not just for Mali but all Indian women, in villages or cities,” he said.

Mali is not the first woman to take action over sanitation concerns. In March, a bride in Telangana state, in southern India, refused to go ahead with her marriage until her fiance had built a toilet. And in April last year, a bride in Kanpur called off her wedding at the last minute for the same reason.

Debates about sanitation have reached the big screen, with Mali’s case echoing the storyline of a just-released Bollywood film called Toilet: A Love Story. The film has a woman threatening to leave her husband unless he builds a toilet. To win back her love and respect, he embarks on a campaign to change his village’s lackadaisical policy on latrines.

“I just can’t fathom how we’ve been able to launch rockets to Mars and the moon but still not been able to build toilets to end open defecation across the country,” the star of the film, Akshay Kumar, told the Times of India this month.