SAN FRANCISCO — Before Donald Trump’s election, Laurence Berland viewed political protest as a sort of curiosity. He was in a good place to see it: San Francisco’s Mission District, once an immigrant enclave in the country’s heartland of radicalism that is increasingly populated by people like him — successful tech workers driving up rents while enjoying a daily commute to Silicon Valley on luxury motor coaches.

Berland regarded the activism of his adopted city with a mix of empathy and bemusement, checking out Occupy Wall Street demonstrations and protests against the gentrification of his own neighborhood. But now there is less distance between him and activists on the street. On a recent day Berland stood with about 100 others — from software engineers like himself to those who work in tech company cafeterias — outside a downtown museum for a rally against President Trump.

“Everyone come closer! We’re going to practice some chanting, and we’re going to get to know each other,” called a woman wearing a union T-shirt with a bullhorn pressed to her lips. The crowd closed in around a banner reading “Workers in Tech Say No Ban No Wall.” A clipboard-carrying organizer approached Berland to ask if he wanted to join a network of grassroots activists, but Berland waved him away. He had already signed up.

In the place that fought against the Vietnam War and for gay rights and, more recently, has been roiled by dissent over the technology industry’s impact on economic inequality, an unlikely alliance has formed in the left’s resistance against Trump. Old-school, anti-capitalist activists and new-school, free-enterprise techies are pushing aside their differences to take on a common foe.

For years, these two strands of liberal America have been at each other’s throats. There’ve been protests against evictions of those who can’t afford the Bay Area’s ever-soaring rents. And think back, not so long ago, to the raucous rallies to block those fancy buses shuttling tech workers from city neighborhoods to the Silicon Valley campuses of Yahoo, Facebook, Apple and Google, where Berland once worked.

Cat Brooks, a Black Lives Matter activist in Oakland, has seen the toll the tech industry has taken on some. Her daughter’s elementary school teacher just moved to a distant suburb after her rent skyrocketed, and Brooks thinks more tech money must find its way into local communities. She nevertheless welcomes the infusion of new energy to the protest arena.

“It’s not about the business of we were here first,” she said. “We’re about the business of how can we support? Division at this time is not helpful.”

Such improbable partnerships scramble the historical protest model that used to pit working-class people against everyone else, said Rory McVeigh, director of the Center for the Study of Social Movements at the University of Notre Dame.

“There are new cleavages that can produce alliances that weren’t possible before,” McVeigh said. “When you feel all of you are being threatened but in different ways … trade-offs are minimized. You realize at times such as that that you need allies more than ever before.”

If all politics is personal, as the saying goes, the moment it got personal for the tech industry was when the Trump administration imposed its initial travel ban on immigrants and refugees from seven majority Muslim nations. The industry prides itself on its openness to immigrants, who comprise about one-quarter of the U.S. technology and science workforce and include the founders of iconic institutions.

Nearly 100 tech companies, including Google, Facebook and Uber, filed a court brief urging suspension of the ban, while Google co-founder Sergey Brin, a Russian immigrant, joined protests at San Francisco International Airport. That was followed by an unprecedented companywide walkout at Google and now, on March 14, nationwide rallies are planned for a “Tech Stands Up” day of protest.

“People in Silicon Valley, it’s really hard to get them excited about things that aren’t technical,” said Anita Rosen, a technology project manager who has started an activist group in the Valley suburb of Mountain View. “But everything that Trump says is the opposite of what we believe. He hates technology. He hates foreigners.”

The morning after the election, Jesse Pickard convened the daily meeting at the technology firm he runs, Elevate. He could see the fear and heartbreak in the faces of his staff of 21, some of whom are legal immigrants. He tried to inspire them to fight for all the things that made them first fall in love with the United States. Then he set about doing that himself.

Pickard wondered if the door-knocking he’d done for Hillary Clinton had been the right use of his talents. “I didn’t feel I was having the impact I could have if I was meaningfully using my design skills,” he said.

And so Pickard launched DeBug Politics, a series of hackathons where teams of software engineers create apps to fight Trump and get more people involved in politics. Winning products include a Chrome browser extension that points viewers to news that doesn’t match their ideological viewpoint, and a tool that allows people to urge followers on social media to contact elected representatives.

Pickard’s company is based out of a three-story converted brewery in San Francisco’s trendy South of Market district. Sitting at a picnic table on the rooftop deck, where the company chef sometimes serves employees lunch and dinner, Pickard acknowledged that tech workers generally had a protected life.

“Prior to the election … you didn’t have a lot to worry about if you got a six-figure job right out of school and got catered lunches every day,” he said. “They had all these left-leaning and progressive opinions, but they didn’t feel like they had to fight very much.”

He’s been to a couple of demonstrations — his first in years — but Pickard thinks he can make more of an impact through technology.

Kai-Ping Yee feels the same. Yee moved to the Bay Area from Canada in 1998, earned his PhD at the University of California, Berkeley, and landed a job as a software engineer in Google’s philanthropic unit in 2007. Now he works at a startup to help immigrants send cash home.

Though he’s never been to a protest, the 40-year-old Yee sees himself as a kindred spirit with his leftist neighbors. “I do sympathize with a lot of the goals and the values behind these protests,” he said, “but have focused my effort on work.”

Part of that work has been creating an online pledge, signed by thousands of technology workers, against building databases for any potential Muslim registries or to aid deportations of immigrants. Yee is a Canadian citizen, though he is a legal permanent resident of this country, and he’s been shocked at having to think about a contingency plan should life in the U.S. become impossible.

“People whose pedigree is knocking on doors and calling representatives and waving signs are getting together with people who design apps,” Yee said. “People are working with people who do really, really different things because they realize it’s an emergency.”

Veteran activists said they are heartened by the civil awakening among tech workers. Debra Cleaver runs VOTE.org, which tries to make absentee voting easier with online tools. She said the greatest help may be tech companies using their copious coffers to fund legal challenges or otherwise fight back. Google, for example, created a $4 million crisis fund to help those affected by Trump’s travel ban.

However, Cleaver cautioned against efforts to “engineer” a way around the effects of Trump policies. “I’m sure they’re all trying” to design new apps and systems to fight Trump, she said, “and they’re going to find out that tech can’t solve this problem.”

Others aren’t so sure about sharing the streets because they don’t think they share the same ultimate goals.

Franki Velez, an Iraq War veteran on disability, stood outside an Oakland rental office recently with other longtime activists and renters fighting eviction. There was not a technology worker in sight, and she worried that they are missing the point anyway. They want to change, but preserve, a system that’s benefited them, she said, while protesters like her want to tear the system down and start from scratch.

“They don’t understand it’s a colonial system that’s never meant to be reformed,” she said.

Still, while their approaches can be strikingly different, Velez’s causes are increasingly being adopted by people not like her.

Velez’s group marched to a Wells Fargo branch to hand over a demand that the bank stop investing in the Dakota Access Pipeline. Two hours later, in the comfortable Silicon Valley suburb of Campbell, biotech executive Michael Clark drew cheers after telling a gathering of anti-Trump activists that he’d closed his Wells Fargo account to protest the pipeline.

Clark grew up in New Hampshire and then in Silicon Valley, when his mother took a job at Apple in the 1990s. He always considered himself a political independent, a moderate. But Trump’s election horrified him and, with a friend who runs a gourmet chocolate shop, he founded a chapter of the national liberal group “Indivisible” in Campbell.

“The country has moved so much to the right that puts me in the middle with people I wouldn’t have previously been aligned with,” Clark said. “It’s interesting that someone like me is on the same side as a lot of socialists.”

The two worlds don’t always intersect, but when they do it can verge on the surreal.

At the anti-Trump protest Laurence Berland attended outside the Children’s Creativity Museum, union leaders railed against the president, as did immigrant cafeteria workers in Spanish. Dana Sniezko, a veteran of local progressive causes who had worried the city was losing its radical edge amid tech-driven yuppie-ization, passed out homemade stickers reading “Resist” and said: “I think San Francisco is waking up.” Passers-by stopped and stared. A handful wearing tags that showed they were in town for a cryptography conference flashed a thumbs-up.

Praveen Sinha, a cryptographer who works at a Silicon Valley digital security firm, began to address the crowd. Sinha, who was born in the U.S., has long been active in liberal causes but despaired that many of his immigrant colleagues were afraid to protest for fear of encountering problems with the Trump administration in the future.

“We’re all in the same boat here,” he told the crowd, bemoaning how Trump was playing on racism to deny people from around the world the chance to contribute to America.

Afterward, Betsy Stone approached Sinha and identified herself as a member of the Socialist Workers Party who spent the previous year talking to voters. “We didn’t find racism or sexism or xenophobia,” she said. “We found people who say, ‘We need jobs like we used to have.’”

Stone, 77, was a blast from the Bay Area’s radical, working-class past. She toiled as a janitor and told Sinha about once being dismissed by an airline company after it hired a contractor who could use immigrant labor for less money.

“Great energy comes from all walks of life,” Sinha told her.

“The whole world cannot come to the U.S.,” Stone countered.

She and Sinha obviously disagreed about much, but then the conversation turned from their differences to their mutual disgust of Trump.

Finally, Stone handed Sinha a copy of a socialist newspaper and went on her way.