A brutal and long-running feud among Democrats for control of a Northeast Philadelphia ward could have citywide implications, reshape the local Republican Party, and potentially shut out some insurgent committee people.

The city's hottest ward fight, which was held Monday night, had everything: shenanigans, legal wrangling, a congressman whipping votes.

On one side of the bare-knuckle race for leader of Northeast Philly's 58th Ward was the incumbent, Jim Donnelly. He's the brother-in-law of Democrat Mike Stack, who just became the first incumbent lieutenant governor in Pennsylvania's modern history to lose in a primary.

On the other side: Jimmy Lewis, a longtime committee person who's allied with U.S. Rep. Brendan Boyle and his brother State Rep. Kevin Boyle, both Democrats.

The Stack and Boyle families have been feuding like rival clans; the Stacks are established, the Boyles newer to the game.

Donnelly defeated Lewis Monday night, 42-40, according to two Democratic sources. But the fight may not be over: Lewis said Donnelly "let at least one person vote who [was] previously disqualified" and "their counting had a lot of problems."

Also, Lewis filed a lawsuit Thursday against the Philadelphia County Board of Elections, arguing that it shouldn't have certified the election of 11 committee people in the 58th Ward. The legal rationale: Committee people must collect 10 signatures to get on the ballot, and the winners were write-in candidates who each received less than 10 votes.

"Since none of these candidates received 10 votes, which would be the number of signatures required to be nominated as a Democratic committee person, none of them should have been computed and/or certified," wrote Lewis' lawyer, Samuel Stretton, in the suit.

Of course, the 11 write-ins also were suspected of favoring Team Donnelly-Stack.

Donnelly said Lewis filed the legal challenge "just to scare me."

City Commissioner Al Schmidt said "it is and has always been the position of the City Commissioners" that a candidate for committee person who wins, even with just one vote, has been elected.

If Lewis's lawsuit is successful, it could potentially invalidate the election of scores of committee people across the city who won via write-in with fewer than 10 votes.

Lewis, meanwhile, said earlier in the day on Monday that he was "nervous" that Donnelly would allow proxies to vote on behalf of committee people who did not attend the evening election. Donnelly sent a letter to committee people on May 22, which said if they couldn't make it, "please let me know as soon as possible and I will get a proxy vote for you."

Lewis said "all we want to do tonight is have a fair election."

Donnelly said the letter "was an error on my part" and "I'm new to this." He said that there would be no proxy votes for ward leader.

As if the intrigue wasn't enough, the election for leader was held at lame-duck Lt. Gov. Stack's house — or rather, his mother's home, where he lives.

Stack and Brendan Boyle have been feuding for ages, and Boyle made calls whipping votes for Lewis, according to several sources.

"Jimmy asked me to endorse him when he came to me and told me he was running. I was happy to do so," Boyle said.

Every four years, this bit of gamesmanship takes place when elections are held throughout the city for ward leader. It's happening in the city's Republican Party, too.

In the GOP, 546 candidates qualified to appear on the ballot for committee person. That's just 16 percent of the 3,376 available committee posts for the party.

Another 350 people won spots as Republican committee people with write-in campaigns, according to the city commissioners. That added a further 10.4 percent to fill the available posts.

But the party is not embracing those 350 people. Philly GOP chairman Michael Meehan, in an email to ward leaders Sunday in advance of Monday's ward reorganization meetings, asserted that state law requires write-in candidates to win votes "in excess" of the number of nomination petitions — 10 — that it would have taken to get their names printed on the ballot, echoing Lewis' contention.

None of the 350 write-in candidates won by 10 or more votes.

Any candidates unhappy with how they are treated by the Republican City Committee, Meehan said, can appeal … to the city committee.

"Whatever the outcome, pro-insurgent or anti-incumbent, people can file appeals," Meehan said.

Mike Cibik, Republican leader of the Fifth Ward in Center City, helped organize the write-in effort, with a website, 50,000 robocalls, and 60,000 recruitment emails.  Cibik, who narrowly lost an election for chairman to Meehan in April 2017, said he plans to again challenge Meehan when the election is held Wednesday.

In other ward news, Berniecrats won the race to lead two Democratic wards in South Philly: the First and the Second Wards.