A little more than a year ago, the Township Committee in this faded factory town became the first municipality in New Jersey to enact legislation penalizing anyone who employed or rented to an illegal immigrant.
Within months, hundreds, if not thousands, of recent immigrants from Brazil and other Latin American countries had fled. The noise, crowding and traffic that had accompanied their arrival over the past decade abated.
The law had worked. Perhaps, some said, too well.
With the departure of so many people, the local economy suffered. Hair salons, restaurants and corner shops that catered to the immigrants saw business plummet; several closed. Once-boarded-up storefronts downtown were boarded up again.
Meanwhile, the town was hit with two lawsuits challenging the law. Legal bills began to pile up, straining the town's already tight budget. Suddenly, many people -- including some who originally favored the law -- started having second thoughts.
So last week, the town rescinded the ordinance, joining a small but growing list of municipalities nationwide that have begun rethinking such laws as their legal and economic consequences have become clearer.
''I don't think people knew there would be such an economic burden,'' said Mayor George Conard, who voted for the original ordinance. ''A lot of people did not look three years out.''
In the past two years, more than 30 towns nationwide have enacted laws intended to address problems attributed to illegal immigration, from overcrowded housing and schools to overextended police forces. Most of those laws, like Riverside's, called for fines and even jail sentences for people who knowingly rented apartments to illegal immigrants or who gave them jobs.
In some places, business owners have objected to crackdowns that have driven away immigrant customers. And in many, ordinances have come under legal assault by immigration groups and the American Civil Liberties Union.
In June, a federal judge issued a preliminary injunction against a housing ordinance in Farmers Branch, Tex., that would have imposed fines against landlords who rented to illegal immigrants. In July, the city of Valley Park, Mo., repealed a similar ordinance, after an earlier version was struck down by a state judge and a revision brought new challenges. A week later, a federal judge struck down ordinances in Hazleton, Pa., the first town to enact laws barring illegal immigrants from working or renting homes there.
Muzaffar A. Chishti, director of the New York office of the Migration Policy Institute, a nonprofit group, said Riverside's decision to repeal its law -- which was never enforced -- was clearly influenced by the Hazleton ruling, and he predicted that other towns would follow suit.
''People in many towns are now weighing the social, economic and legal costs of pursuing these ordinances,'' he said.
Indeed, Riverside, a town of 8,000 nestled across the Delaware River from Philadelphia, has already spent $82,000 defending its ordinance, and it risked having to pay the plaintiffs' legal fees if it lost in court. The legal battle forced the town to delay road paving projects, the purchase of a dump truck and repairs to town hall, officials said. But while Riverside's about-face may repair its budget, it may take years to mend the emotional scars that formed when the ordinance ''put us on the national map in a bad way,'' Mr. Conard said.
Rival advocacy groups in the immigration debate turned this otherwise sleepy town into a litmus test for their causes. As the television cameras rolled, Riverside was branded, in turns, a racist enclave and a town fighting for American values.
Some residents who backed the ban last year were reluctant to discuss their stance now, though they uniformly blamed outsiders for misrepresenting their motives. By and large, they said the ordinance was a success because it drove out illegal immigrants, even if it hurt the town's economy.
''It changed the face of Riverside a little bit,'' said Charles Hilton, the former mayor who pushed for the ordinance. (He was voted out of office last fall but said it was not because he had supported the law.)
''The business district is fairly vacant now, but it's not the legitimate businesses that are gone,'' he said. ''It's all the ones that were supporting the illegal immigrants, or, as I like to call them, the criminal aliens.''
Many businesses that remain are having a hard time. Angelina Guedes, a Brazilian-born beautician, opened A Touch From Brazil, a hair and nail salon, on Scott Street two years ago to cater to the immigrant population. At one point, she had 10 workers.
Business quickly dried up after the law against illegal immigrants. Last week, on what would usually be a busy Thursday afternoon, Ms. Guedes ate a salad and gave a friend a manicure, while the five black stylist chairs sat empty.
''Now I only have myself,'' said Ms. Guedes, 41, speaking a mixture of Spanish and Portuguese. ''They all left. I also want to leave but it's not possible because no one wants to buy my business.''
Numerous storefronts on Scott Street are boarded up or are empty, with For Sale by Owner signs in the windows. Business is down by half at Luis Ordonez's River Dance Music Store, which sells Western Union wire transfers, cellphones and perfume. Next door, his restaurant, the Scott Street Family Cafe, which has a multiethnic menu in English, Spanish and Portuguese, was empty at lunchtime.
''I came here looking for an opportunity to open a business and I found it, and the people also needed the service,'' said Mr. Ordonez, who is from Ecuador. ''It was crowded and everybody was trying to do their best to support their families.''
Some have adapted better than others. Bruce Behmke opened the R & B Laundromat in 2003 after he saw immigrants hauling trash bags full of clothing to a laundry a mile away. Sales took off at his small shop, where want ads in Portuguese are pinned to a corkboard and copies of the Brazilian Voice sit near the door.
When sales plummeted last year, Mr. Behmke started a wash-and-fold delivery service for young professionals.
''It became a ghost town here,'' he said.
Immigration is not new to Riverside. Once a summer resort for Philadelphians, the town became a magnet a century ago for European immigrants drawn to its factories, including the Philadelphia Watch Case Company, whose empty hulk still looms over town. Until the 1930s, the minutes of the school board meetings were recorded in German and English.
''There's always got to be some scapegoats,'' said Regina Collinsgru, who runs The Positive Press, a local newspaper, and whose husband was among a wave of Portuguese immigrants who came here in the 1960s. ''The Germans were first, there were problems when the Italians came, then the Polish came. That's the nature of a lot of small towns.''
Immigrants from Latin America began arriving around 2000. The majority were Brazilians attracted not only by construction jobs in the booming housing market but also by the presence of Portuguese-speaking businesses in town. Between 2000 and 2006, local business owners and officials estimate, more than 3,000 immigrants arrived. There are no authoritative figures about the number of immigrants who were -- or were not -- in the country legally.
Like those waves of earlier immigrants, the Brazilians and Latinos triggered conflicting reactions. Some shopkeepers loved the extra dollars spent on Scott and Pavilion Streets, the modest thoroughfares that anchor downtown. Yet some residents steered clear of stores where Portuguese and Spanish were plainly the language of choice. A few contractors benefited from the new pool of cheap labor. Others begrudged being undercut by rivals who hired undocumented workers.
On the town's leafy side streets, some residents admired the pluck of newcomers who often worked six days a week, and a few even took up Capoeira, the Brazilian martial art. Yet many neighbors loathed the white vans with out-of-state plates and ladders on top parked in spots they had long considered their own. The Brazilian flags that flew at several houses rankled more than a few longtime residents.
It is unclear whether the Brazilian and Latino immigrants who left will now return to Riverside. With the housing market slowing, there may be little reason to come back. But if they do, some residents say they may spark new tensions.
Mr. Hilton, the former mayor, said some of the illegal immigrants have already begun filtering back into town. ''It's not the Wild West like it was,'' he said, ''but it may return to that.''