Maxim Shipenkov / EPA Russian police officers detain alleged illegal immigrants during a raid at a vegetable warehouse in Moscow on Oct 14, 2013

There was no easy way for the mayor of Moscow to respond to this weekend’s race riots. On Sunday night, a violent mob clashed with police in the south of the city, hurling bottles, destroying property and screaming for a purge of minorities from Central Asia and the Caucasus. Their leaders claimed it was revenge for the unsolved murder last week of a Russian man at the hands of a dark-skinned migrant worker. But while Mayor Sergei Sobyanin was quick to condemn the tactics of the mob, he found it hard to distance himself from its logic. Just this summer, during the city’s mayoral race, Sobyanin was the one who brought xenophobia into the political mainstream. Now he was forced to reap what he’d sown.

So his reaction to the violence, bizarre as it seems, was understandable on Monday morning, when he briefed President Vladimir Putin on the incident. Instead of pledging to rebuild or at least protect the vegetable warehouse that the racist mob had ransacked, Sobyanin ordered it to close down for using migrant labor. And, instead of trying to calm the immigrants who were the targets of the violence, he ordered raids on street markets to arrest more than a thousand migrants at random. “We are carrying out a series of inspections not only at the [damaged] warehouse but other markets in Moscow in order to establish order,” the mayor told Putin. Almost as an afterthought, he mentioned that police had arrested the organizers of the riot and charged them with “hooliganism.”

(MORE: Moscow Rioters Lash Out Against a ‘Migrant’ Murderer)

His focus on the threat of illegal migrant workers — rather than the threat of skinheads and nationalists — was in line with the rhetoric he trotted out this summer. During an interview in May with a Moscow daily, Sobyanin, who previously served as Putin’s chief of staff, made no bones about his attitude toward foreigners. “People who don’t speak Russian well, who have a totally different culture, they are better off living in their own country,” the incumbent mayor said. “That is why we do not welcome their adaptation in Moscow.”

In late July, he ordered a massive dragnet to arrest illegal immigrants at bazaars across the city. Thousands of them were rounded up, mostly migrant workers from Vietnam. By August, the city’s jails were so overcrowded with these detainees that Sobyanin ordered the construction of a camp to house them in an industrial yard equipped with tents and port-o-potties. State-run television networks meanwhile touted the effort as a sign of Sobyanin’s toughness on illegal immigration.

Nikolai Petrov, an expert on local elections at the Carnegie Endowment in Moscow, says this campaign strategy lifted a long-standing taboo among the ruling party. Previously, xenophobic rhetoric was the providence of fringe politicians and right-wingers, while the elites around Putin “saw it as uncouth and even dangerous” to play on racist sentiments, says Petrov. The dangers became particularly clear in December 2010, when football fans and skinheads staged a riot at the Kremlin walls, beating dozens of dark-skinned passersby and leaving swastikas scrawled on surrounding buildings. That was the most violent display of ethnic hatred to erupt in Moscow under Putin’s rule, and it reminded the elites that xenophobia is a force best kept contained.

(MORE: Russia’s Elections: Even in Defeat, Anti-Putin Camp Finds Victory)

But as last month’s mayoral election approached, Sobyanin’s campaign team seemed unable to resist the political temptation. Polls showed anti-immigrant sentiment was high among the electorate, and it was a far easier issue for Sobyanin to turn in his favor than corruption or tawdry social services. “So Sobyanin not only failed to dampen these racist feelings, not only turned a blind eye to manifestations of racism, but he took up this anti-immigrant rhetoric as the basis of his campaign,” Petrov says.

The Moscow mayor was not the only politician trying harness this energy. Particularly among young men, aggression toward immigrants is no less ferocious in Russia than in many European countries inundated with foreign laborers. But Russia has no independent party capable of representing the political far right; the Kremlin has not allowed such movements gain a foothold in the electoral processes. The country’s right-wing youth have thus tended to coalesce around football clubs and other informal groups, giving rise to a fierce and politically marginalized subculture of nationalism.

Sobyanin’s main rival in last month’s election, the opposition leader Alexei Navalny, has long been known to associate with nationalist groups, and he had a strong chance of garnering their support if Sobyanin failed to co-opt them in the lead-up to the election. After this weekend’s riot in Moscow, Navalny again showed his sympathy for the anti-immigrant movement, lashing out against the “hordes of legal and illegal immigrants” who live and work around the city’s bazaars. “From there they crawl out to the surrounding neighborhoods,” Navalny wrote on his blog on Monday. “They’re not going to die of hunger when they can’t find work, not when they can snatch a purse in the subway or take somebody’s money at knifepoint in an elevator.” So the rioters, Navalny suggested, were justified in pushing back against the immigrant threat. “If there is no fair way to resolve conflicts and problems, then people will create it themselves, with primitive and desperate measures,” he wrote.

Over the weekend, these measures caused dozens of injuries, hundreds of arrests and millions of dollars in property damage. But neither of the two leading candidates in last month’s mayoral election would condemn them outright. Such are the new political realities of Moscow, where xenophobia, as Petrov puts it, “is now par for the course.”