In 2013, Randy Dillard found himself on the wrong side of an eviction notice.

“I was numb,” he says of the moment he discovered the notice from his landlord. “I was frightened. I was scared. I didn’t know what to do.”

A single parent of five and a bricklayer by trade, Dillard, 62, got the eviction letter not long after he returned home from a months-long stay in the hospital, where he was receiving treatment for emphysema. He was losing his Bronx apartment, he learned, because the Section 8 housing program that subsidized his rent had stopped making payments to his landlord because of the property’s dilapidated condition. Despite the fact that the apartment’s pest infestation and its leaky plumbing were a result of the owner’s own negligence, Dillard says his landlord used the subsidy cutoff as an excuse to try to toss his family into the street.

“No one should have to look in their daughter’s eyes while she’s crying and saying she doesn’t want to go to a shelter, and you have to hold back your own tears and tell her that everything is going to be all right even though you don’t know if it will be all right,” he says. “No one should have to do that.”

For most tenants, this would have been the beginning of an unmitigated nightmare. They could have ended up in a shelter. They could have lost their jobs. Their kids might have had to move to a new school. They might have suffered a heath crisis, or something worse.

Dillard, though, was lucky. A neighbor told him about a local organization that offered free legal counsel to beleaguered tenants, a rare service in a city where only a tiny percentage of renters have customarily had access to housing attorneys. Dillard got a lawyer and a legal battle ensued, one which saw him return time and again to housing court. Finally, after three years of motions and proceedings and paperwork, his landlord sensed defeat and dropped the frivolous case.

The court fight enabled Dillard to stay in his apartment as long as he pleased. It also activated him.

“If I hadn’t had an attorney, I would have been evicted,” he says. “Without legal knowledge, there is no way I would have been able” to fight in court, he added.

After his eviction scare, Dillard wanted other tenants to benefit from the same sort of legal support he’d received, so he became an organizer with a Bronx-based housing-rights organization called Community Action for Safe Apartments, or CASA. He also took on a leadership role with the Right to Counsel NYC Coalition, the motivating force behind a visionary movement to guarantee all low-income tenants in New York City a right to legal counsel.

The coalition, which brings together legal-aid attorneys, tenant-rights groups, unions, faith organizations, and more, formed in 2014 and quickly started recruiting supporters for its cause. Dillard and members held town-hall meetings and panel discussions, threw block parties, and published reports. They took local officials on tours of housing court and pushed their message in TV and print media. They won the support of dozens of community boards, all five borough presidents and a wide range of prominent officials, including Jonathan Lippman, the former chief judge of the New York State Court of Appeals. This summer, they finally prevailed.

On August 11, Mayor Bill de Blasio signed legislation that, when fully implemented, will dedicate $155 million a year to ensure that all low-income tenants in New York City have access to legal representation in housing court. The right-to-counsel legislation is the first of its kind in the country, but it won’t be the last. From Philadelphia and Baltimore to San Francisco and Washington, DC, a diffuse but savvy movement is taking shape to ensure that tenants get the legal assistance they need when landlords try to kick them to the curb. In doing so, it aims to decrease evictions, slow gentrification, and mitigate the devastating social effects of home dispossession. It hopes to help solve the housing crisis that is roiling cities across America.

Every year in this country,” writes Matthew Desmond in Evicted, his Pulitzer Prize–winning book on the eviction crisis, “families are evicted from their homes not by the tens of thousands or even the hundreds of thousands, but by the millions.” The evicted are generally low-income, low-wealth renters, many of them people of color, and their dispossession leads to intensifying impoverishment, isolation, stigmatization and all sorts of debilitating traumas and crises.

What’s more, many of these evictions could be prevented if our court system weren’t so shamelessly slanted against the poor. In New York, for instance, before the City started ramping up funding for legal-assistance programs, only about 1 percent of tenants who appeared in housing court had attorneys, while almost all of the city’s litigious landlords were able to afford and obtain legal counsel. Advocates say this disparity encouraged landlords and developers to intimidate tenants and pursue frivolous cases, fueling unfair evictions, homelessness, the loss of affordable housing, and gentrification.

New York City’s new law aims to change this dynamic, and there is excellent evidence that it will succeed. Even before de Blasio signed the “right to counsel” legislation earlier this month, the City had started pouring money into legal-assistance programs for tenants, increasing such funding from $6 million to $62 million between 2013 and 2016. During those years the percentage of court-bound tenants with legal representation increased from 1 percent to 27 percent and evictions in the city decreased by 24 percent. Roughly 40,000 people avoided eviction between 2015 and 2016 as a result—a promising portent for the city’s new law.

“It is going to be transformative,” says New York City Council member Mark Levine, who sponsored the “right to counsel” bill. “It will entirely change the tenant-landlord relationship in this city.”

For years, Levine says, housing court “has been a weapon that unscrupulous landlords have used to pressure vulnerable tenants because they knew there would never be a lawyer on the other side, and this has fed the homelessness crisis.” It has also led to the “hemorrhaging” of rent-regulated apartments. Now all that will start to change. “The potential benefits of this are just massive,” he adds.

Other cities, inspired by New York, have also started to embrace this vision, which imagines a future where those involved in life-altering civil cases have a guaranteed right to counsel.

In late June, Philadelphia set aside $500,000 to pay for public-interest attorneys to help tenants threatened with eviction. As in New York, Philly’s renters are in dire need of such support. The city sees roughly 20,000 eviction filings each year, according to a January report by the Reinvestment Fund. And the majority of these are in low-income African-American neighborhoods.

“This money will double the number of attorneys currently dealing with this crisis and it will be the first time the City has established a fund to give tenants a chance at legal defense,” says Helen Gym, a Philadelphia City Council member and tenant-rights advocate. “We are not quite able to fund [these programs] at New York’s level,” she adds, “but we are trying to move towards that.”

In Baltimore, meanwhile, City Councilman Robert Stokes introduced a bill in July that seeks to amend the City’s charter and create a legal-assistance fund for tenants, to be financed by revenue from fines and fees. The legislation comes after an in-depth investigation by The Baltimore Sun found that the city’s housing court “routinely works against tenants, while in many cases failing to hold landlords accountable when they don’t ensure minimum standards of habitability.”

Washington, DC, too, has taken strides toward a right to counsel in recent months.

In March, the City allocated $4.5 million to support eviction-defense work during the coming fiscal year. This substantial chunk of change is “a building block to establishing a right-to-counsel in certain cases,” says Beth Mellen Harrison, a supervising attorney and project director at the Legal Aid Society of the District of Columbia. “The constitution enshrines a right to counsel in criminal cases, but it doesn’t in civil cases.”

Harrison, like so many others, believes this should change, especially in cases related to housing, child custody, public benefits, and other basic human needs.

To press her point, she describes the case of a client named Alicia Smith. Smith lives in a rent-controlled apartment in Washington, DC, where she pays $480 a month. Some years ago, her landlord applied in housing court to hike her rent by $300 a month. That increase would have forced Smith, who works as a home health-care professional and has a daughter with special needs, to give up the apartment she’s lived in for 14 years. It would have driven her out of the neighborhood too, a neighborhood where her daughter’s school and doctor and a network of supportive friends are located. Moving would have been a devastating disruption, and so Smith went to the Legal Aid Society, where Harrison took her case.

“She is so wonderful, so excellent. My daughter loves her, I love her,” says Smith of Harrison, who has advised and advocated for her for roughly three years. “I don’t know what I would do if I was not able to have this type of assistance or get this help, because I know I would not be in a position to be able to pay out of pocket for an attorney.”

For now Smith and her daughter are safe in the home they’ve had for more than a decade. But her fight, and the broader fight for a right to counsel, continues.