San Rafael City Councilman Marc Levine declared victory Wednesday in his upset bid for the new North Bay Assembly seat, but Assemblyman Michael Allen would not concede the bitter battle that pitted two Democrats against each other.

With tens of thousands of uncounted ballots in Sonoma and Marin counties, the final tally may not be decided for weeks. But Levine expressed confidence Wednesday that his narrow 1,663-vote lead over Allen would hold up.

"The time for campaigning is over, and now we govern," Levine said. "We are confident that we'll have the votes to win, as we don't see a reversal in the voting trends."

Levine captured 50.6 percent, or 68,189 votes, of the ballots counted Tuesday while Allen received 49.4 percent, or 66,526 votes.

"Right now there's so many uncounted, and there's still a small gap," Allen said. "Given that the difference between us is about 1,500 or 1,600 ballots, we think it's not respectful to concede when they're still counting."

There are about 46,000 uncounted absentee and provisional ballots in Marin County alone, according to Elaine Ginnold, registrar of voters in Marin. And in Sonoma County, the exact number of uncounted ballots is unknown, but could amount to about 15,000 votes, said elections chief Janice Atkinson.

The fight for the 10th Assembly District seat was closely watched in Sacramento, one of about two-dozen races across the state to pit members of the same party against each other under California's new top-two primary system.

The system, which debuted in June, allows the top two vote-winners in the primary to advance to the general election, regardless of party affiliation. It gave voters disappointed with the status quo more options to stick with their party yet still vote for change, resulting in tougher challenges for some incumbents across the state, said David McCuan, a Sonoma State University political scientist.

"You're going to see a lot more of this kind of stuff as we move forward. More insurrections," McCuan said. "It has the potential to make these dramatic changes in how business is done in Sacramento."

The close race mirrors another Democratic matchup in Southern California, where incumbent Assemblywoman Betsy Butler trails challenger Richard Bloom by about 200 votes.

"The Democrat-on-Democrat warfare is never pretty, and it's unfortunate that it had to happen," said longtime political consultant Steve Maviglio, a spokesman for the Assembly Democrats. "It was obviously a hard-fought race, with a lot of money spent. And, at the end of the day, the winner is a Democrat, and they'll quickly come to Sacramento and we'll see that the real difference is between the two parties."

Allen began serving in the Legislature in 2010 and quickly rose to become the assistant majority leader in the Assembly, where he was set to lead a pension committee in the upcoming term. Assembly Speaker John Perez campaigned for Allen, and independent expenditure committees poured more than $700,000 into his campaign in the final weeks.

"He's an important part of the Speaker's team," McCuan said of Allen. "Michael's a labor guy, and the Speaker's a strong labor guy. And labor generally did well yesterday, but not in Michael's district."

When legislative districts were redesigned, Allen moved from Santa Rosa and rented an apartment in San Rafael to run for the seat, which may have upset some Marin County voters, McCuan said. Rather than supporting Levine, many voters may simply have voted against things they didn't like, he said.

"They could vote against Sacramento, they could vote against business as usual, they could vote against massive amounts of spending, they could vote against a candidate moving into the district," McCuan said. "Oh, and as a bonus, you could vote for a local guy from Marin."

Both Allen and Levine planned to travel to Sacramento this morning to attend a caucus meeting for Assembly Democrats.

"The Speaker of the Assembly did reach out to me to congratulate me very early this morning, and invited me to the training in Sacramento," Levine said.

Allen said that's the typical procedure when Assembly races are too close to call. In the 2010 primary, Allen had to wait nearly three weeks to find out he had won the election, he said.

"At this point, we don't know," Allen said. "He (Levine) may have won, he may not have won. There have been situations where people have shown up for the caucus and then found out weeks later that they didn't win."

Even so, Allen acknowledged that Levine holding a lead throughout the night was "auspicious."

"If you're going to be involved in politics, you don't take it personally," Allen said. "The vagaries of why someone wins an election are unclear, especially in these close elections."

Levine said he had not heard from Allen, but he congratulated his opponent on a hard-fought campaign.

"I'm proud of the campaign that we ran, and grateful that voters in the North Bay stood by us on Election Day," Levine said. "No one gave our campaign a chance in the beginning, and we beat all expectations."