Virginia Republican gubernatorial candidate Corey Stewart discusses a murder case involving undocumented immigrants at a campaign rally Saturday in Harrisonburg, Va., with his wife, Martha. (Timothy C. Wright/For the Washington Post)

Corey Stewart led a rally against illegal immigration on the steps of a historic courthouse Saturday after two local restaurants, bowing to threats of boycotts, backed out of hosting the firebrand Republican running for Virginia governor.

“You know you’re winning the battle when your opponents try to shut you down,” Stewart told the crowd.

Stewart’s campaign originally booked a Harrisonburg restaurant for his “Rally to End Illegal Immigration.” But the restaurant canceled last week after receiving phone calls and emails from members of Harrisonburg Indivisible and other local activists. Complaining about Stewart’s “divisive rhetoric,” they told restaurant managers they would no longer patronize the eatery if it hosted the rally.

Stewart’s campaign then reserved a room at a second restaurant, but that got canceled as well after another round of emails and phone calls. His team scrambled Friday to get a permit to hold the rally at the Rockingham County Courthouse, where on Saturday Stewart declared a victory for free speech.

Stewart used his canceled reservations saga in fundraising appeals as a critical campaign finance deadline approached Friday, claiming that the activists were on the payroll of financier George Soros — something the activists said was not true.

“George Soros and his group of paid liberal activists, Indivisible, have launched an attack intending to stop my rally against illegal immigration,” one fundraising email reads. “They are trying to convince people that my ideas are unreasonable. But how can protecting the safety of American citizens and upholding the rule of law be considered unreasonable?”

Stewart is in a three-way race for the GOP nomination with former Republican National Committee chairman Ed Gillespie and state Sen. Frank Wagner (Virginia Beach). On the Democratic side, Lt. Gov. Ralph Northam and former congressman Tom Perriello are vying for their party’s nod. Gov. Terry McAuliffe (D) is prohibited from seeking reelection this year under the state Constitution, which bars governors from serving consecutive terms. Both nominations will be decided in June 13 primaries.

Stewart was chairman of Donald Trump’s Virginia campaign, and he is seeking the governorship in similarly provocative style. Far behind Gillespie in fundraising and endorsements, the chairman of the Prince William Board of County Supervisors has often sought to stoke controversy and attract counterprotesters to his events.

Stewart has used heated rhetoric regarding illegal immigrants, vowing to “hunt them down.” He has, at times, called the preservation of the state’s Confederate monuments the most important issue in the governor’s race. His campaign got lots of mileage out of video showing liberal protesters mobbing him in Charlottesville in February, when he held a rally to defend a Robert E. Lee statute that city leaders want removed.

Harrisonburg looked like fertile ground for that kind of visual. Nicknamed “the Friendly City,” it is a college town with a population more diverse than its Shenandoah Valley surroundings might suggest. The Latino population has grown from just under 9 percent in 2000 to nearly 19 percent in 2015, according to census figures. About 17 percent of residents are foreign-born, up from 9 percent in 2000. Church-based refugee resettlement programs and a poultry industry dependent on immigrant labor are behind the trends.

Yet Saturday’s rally was no repeat of the Charlottesville mob that shouted Stewart down. The event drew only about 20 supporters and 10 protesters. Except for a man who shouted “Scumbag!” at Stewart, the protesters were not disruptive. They stood silently around a sign that said, “No matter where you are from, we’re glad you’re our neighbor,” in Spanish, English and Arabic.

In a conversation after the rally, Stewart stressed that he does not oppose legal immigrants, only those who come to the country illegally.

Danny Maybush, a truck driver in a “Make America Great Again” cap, said he only opposed immigrants who “come up here and want to get a better life and start some stupid gang.”

“I like that it’s a melting pot,” he said of the country. “I have a Hispanic family that lives near me, and they came here legally, and they all work hard. We had a big snow the year before [last]. I was going to snowblow their driveway but they already had seven people out there going at the driveway.”

The on-again, off-again lead-up to the rally ultimately proved to be more dramatic than the event itself. Stewart began by unfolding a piece of paper with three mug shots. They were of three illegal immigrants from El Salvador who were charged last week in the death of a Lynchburg teenager, 17-year-old Raymond Wood. Stewart went on to ask for a moment of silence for Wood and all the other “boys and girls in Virginia and across the country who have been murdered by illegal aliens.”

That was the kind of rhetoric that John Schaldach, a Harrisonburg Indivisible organizer, said he objected to when he organized the email and phone call campaign to the two restaurants, Dave’s Taverna and Wood Grill Buffet.

“Ask them to cancel the Stewart event,” his email to activists said. “Let them know if they don’t, you will not patronize Dave’s and you will ask your friends to do the same. Please be kind to the manager! . . . Thank you for taking action on this critical local issue! Together we can make sure Corey Stewart knows his message is not welcome here.”

Schaldach, a 46-year-old piano technician, did not dispute Stewart’s right to express his views in public, as the candidate ultimately did at the courthouse. But he said the activists had a right to let local restaurants know that they opposed his message.

“My concern is that his rhetoric is divisive,” he said. “The effect of his rhetoric is a segment of our community ends up feeling isolated. . . . He talks about illegal immigration, and then he talks about crime and he mixes it all together. And you come out the other end, and you think immigrants are related to crime. When, in fact, the opposite is true. . . . There’s no evidence they commit more crimes.”

In linking the protest to Soros, Stewart was echoing a claim White House press secretary Sean Spicer and others have lobbed against Indivisible activists who have sought to disrupt GOP town hall meetings nationally.

Soros has pumped millions into liberal causes since the 2004 election cycle. But Soros spokesman Michael Vachon has disputed claims that Soros has paid Indivisible protesters or picked up their transportation tab. Schaldach said his group gets no money from Soros.

The Harrisonburg group is one of more than a thousand Indivisible spinoffs created nationwide and organized around the Indivisible Guide, an organizational how-to manual drafted by former Democratic staffers. Stewart’s campaign noted that some of the aides now work for Soros-funded organizations, such as the National Immigration Law Center.