On soggy, windy Sunday, I witnessed American democracy — in its raw and primal form — in action at a San Francisco labor hall. It was beautiful, and it was ugly.

The occasion was the Assembly District 17 delegates election, a generally obscure exercise in democracy that took place throughout the state this weekend. The 14 delegates selected at the District 17 level, which covers the eastern half of San Francisco, get to attend the California Democratic Party convention in May, where they will swill beverages and rub elbows with minor and major political personalities, as well as vote on resolutions that might or might not influence policy. Normally, these district elections excite interest among only party hacks and political wonks. But in case you hadn’t noticed, things are anything but normal these days.

On Sunday morning, while the rest of the city was still enjoying its coffee, a shockingly long line of San Francisco Democrats braved the rain and wind to cast their votes in the District 17 delegate race at the Laborers International Union hall in the Mission. The line snaked out of the building on 18th Street, rounded the corner on Shotwell, and turned right on 19th, where it finally ended in the wet and gloomy distance. Many people waited for as long as two hours under the leaky skies to vote.

The Trump effect has clearly hit San Francisco. No fewer than 1,500 Democrats turned out for this vote, according to artist Debra Walker, convener for the District 17 election — far more than for the last election, in 2015, when about 900 showed up, she said.

So that’s the good news for all those still in shock after November.

“The message today is that we’re alive and well, and we’re fighting back,” said Brian Salkin, one of the dozens of San Franciscans who threw his hat into the delegates race.

But any hope that the Democratic Party in San Francisco would blissfully unite against Trump was dashed by bitter divisions on full display Sunday morning. The friction that tore apart the national party during the primary season, and has pitted local progressives against centrists, grew red hot as the Democrats’ warring factions converged on the labor building.

“This is Bernie versus Hillary all over again,” said one young voter standing in line, who preferred not to give his name. He supported the so-called Rebuild slate, whose campaign was spearheaded by Assemblyman David Chiu, a pillar of the centrist coalition. The opposing Reform slate included a progressive chorus line of Sanders supporters, tenant organizers, LGBTQ activists and police-reform advocates.

As I entered the building, Reform slate members were fuming about what they alleged was “election-rigging” by their centrist opponents. A line of Bauer rental buses parked in front — observers counted at least five vehicles — was disgorging a steady stream of Chinese-speaking men and women. No one stopped them as they went directly inside the building, cutting in front of the long line of people who were patiently standing in the rain.

I spotted one middle-aged Chinese American woman, who declined to give her name, filling out multiple ballots. When challenged by an independent election observer, she became upset and said she was voting on behalf of relatives who could not read English. Meanwhile, at the table where the woman was filling out ballots, Rebuild slate organizers handed out doughnuts, tangerines, granola bars and bottled beverages to those who had just performed their civic duty.

“This is just more of the same corrupt stuff we saw in the Democratic primaries,” said Reform candidate Ben Becker, as he tried to physically block people from crashing the voter line. The young, ponytailed Becker and his wife, Claire Lau, had co-founded San Francisco Berniecrats, an organization that grew out of the Sanders campaign and became the main engine behind the Reform slate. “Hundreds of people are being bused in from Chinatown today — they don’t know who they’re voting for,” said Becker. “They’re just being told how to vote by David Chiu and his people.”

“We’re obviously not anti-immigrant or anti-Chinese,” said former Supervisor David Campos, a Reform slate organizer. “But this is one of the worst displays of manipulating the process I’ve seen in years.”

I found Chiu in front of the building, directing people as they exited the rental buses. He agreed the delegate election was “a chaotic process,” but he strongly denied that his centrist faction was “stacking the vote,” as Campos charged. “There are multiple slates, and everyone is asking people to vote for their candidates,” Chiu said. “I see this as a positive thing — our entire city and state is engaged in the process.”

“We paid for bus rental costs out of my campaign account,” Chiu acknowledged, adding that these expenditures will be reflected in his treasurer's next report. As for some Chinese-only speakers having their ballots filled out by others, he said: “There were no bilingual ballots, so people needed help.”

But Walker, the election convener, disputed this. “There’s no language problem with the voting,” she said. “The ballot is just a list of names. And if they can’t read the names in English, there are Chinese-language translations.”

Like Chiu, newly elected state Sen. Scott Wiener, D-San Francisco, who also backed the Rebuild slate, put the best possible spin on the tension-filled morning. “This is the ultimate expression of democracy, whatever side you’re on. At the end of the day, we’re all on the same side. We’re all going to unite against the existential threat to our democracy.”

But that unity seemed a distant mirage as I left the building, where I bumped into Kimberly Alvarenga, who lost a hard-fought battle for District 11 supervisor in November by only a few hundred votes. A soaked Alvarenga had been working the line outside the building for three hours on behalf of the Reform slate.

“There were elders, differently abled people, mothers with young kids, all standing in the rain, waiting their turn to vote,” she said. “And then all those people came pouring off the buses and cut in front of them, so they had to wait longer. That’s disingenuous; that’s disrespectful. Democracy needs to be a fair process.”

In the end, the progressive slate prevailed, by a slight margin, taking eight of the 14 seats. Becker was among the winning candidates. Despite winning a majority, progressives were still fuming. “If not for the questionable tactics by the other side, it would have been a progressive sweep,” said Campos. “It’s sad and embarrassing that there was such a horrible process.”

Sunday’s top vote-generator was a member of the centrist slate, Theo Ellington, a 27-year-old public affairs executive for the Warriors. In the midst of Sunday’s mad political circus, the politically ambitious Ellington, whom my family has called “Mr. Mayor” ever since he went to high school with my son, told me, “My job is to bring people together.”

He will have his hands full.

San Francisco Chronicle columnist David Talbot appears Sundays, Tuesdays and Thursdays. Email: dtalbot@sfchronicle.com