Rigel Oliveri is an associate dean at the University of Missouri Law School and formerly practiced law in the Justice Department’s Civil Rights Division.

The U.S. Court of Appeals for the 9th Circuit issued an opinion last month rooted in both the Constitution and common sense: It ruled that people seeking roommates are shielded from fair-housing laws by the First Amendment’s protection of free association. In so doing, the court upended a core assumption shared by many fair-housing advocates. Paradoxically, this ruling was the best outcome for those of us who care about protecting the rights of people to be free in their choice of housing.

Here’s the background: The Fair Housing Act prohibits denying housing to someone based on a protected characteristic, such as race or religion. It also prohibits making or publishing discriminatory advertisements for housing. Both the person placing the ad and the newspaper that runs it can be liable under this provision. As a result, newspapers have the incentive to screen out discriminatory housing ads, and such messages have essentially vanished from the classified pages.

Then the Internet came along, and sites such as Craigslist became an increasingly popular way to advertise housing. Additionally, the Telecommunications Act of 1996, which immunizes Web sites from liability for user-supplied content, was signed into law. One practical effect of this law is that Web sites have no legal incentive to screen out discriminatory housing ads.

As a former civil rights lawyer, I was alarmed by this turn of events, anticipating a torrent of bigoted advertisements by landlords. As an academic, I was intrigued by the opportunity it presented for research. So two years ago I undertook a study of 10,000 housing ads posted to Craigslist from across the country. I divided my sample in half, 5,000 ads for rentals and 5,000 ads for roommates, and analyzed each group for discriminatory statements.

What I found was both revelatory and obvious: The vast majority of discriminatory ads were taken out by people seeking roommates — that is, by ordinary individuals looking for someone to help share the rent. Almost none of the problematic ads were posted by landlords seeking tenants.

No doubt this is partly due to the fact that landlords, as housing professionals, are aware that the law prohibits them from posting discriminatory ads, while ordinary roommate-seekers are oblivious. But some of this is surely due to the intimate nature of the roommate relationship. Roommates share close quarters and often spend a good deal of time together. Things that might be important to a roommate-seeker — for example, whether the prospective roommate keeps a kosher kitchen or speaks Mandarin as a first language — would be both bizarre and illegal for a landlord to consider when renting to a tenant.

My research also revealed that most of the ads expressing a racial, religious or ethnic preference were placed by members of minority groups who were seeking roommates like themselves.

No matter their motives, however, these people were in violation of the Fair Housing Act and subject to civil prosecution. Yet this cannot be a proper application of the law. Just as it would be abhorrent for the government to prevent people of different races, ethnicities or religions from living together, it would be equally offensive to block people of a shared race, ethnicity or religion from living together. The right of free association should allow those seeking roommates to limit their searches to people with whom they will be comfortable.

Which brings us to the 9th Circuit’s recent decision. In ruling that the First Amendment protects people’s ability to advertise and exercise preferences for roommates, the court brings the law in line with a view surely shared by many across all segments of society.

The decision may look like a setback for civil rights, yet it also has pro-civil-rights implications. If we have a right to live with whomever we choose, then people in non-traditional living arrangements — unmarried couples, for instance — should be protected from governmental intrusion.

If the 9th Circuit had ruled differently, the potential for backlash would have been enormous and support for a crucial civil rights law would have been undermined. Vigorous support for fair housing is as important as ever, but interfering in people’s roommate choices is the wrong way to go about it.