Hillary Clinton greets supporters as she arrives at a campaign stop in Long Beach, Calif., June 6. (Mike Blake/Reuters)

It lasted longer than the 1979 conflict between China and Vietnam, but California's slow-moving count of provisional and mail-in ballots is finally over — and as expected, Hillary Clinton won.

Wednesday night, after ballots were finally processed in San Mateo County, Clinton had won 2,745,293 votes to 2,381,714 for Bernie Sanders. The eventual margin was 363,579 votes, or 7.1 percentage points, closer than the 2008 primary between Clinton and Barack Obama.

It was closer, too, than Sanders seemed to get on election night, when a rout bigger than any poll had suggested effectively ended the Democratic primary. Since then, Sanders added 879,671 votes to his California total; Clinton added 804,713 votes. As expected, most of the outstanding ballots left on June 7 were cast for Democratic candidates, and as expected, they broke for Sanders. (For a sense of California's scale, Sanders won more votes in the long provisional/mail-in count than he won, total, in the New York primary — 820,256 votes.)

As the count dragged on, Sanders won a few counties that seemed to break the other way on election night. The last of them — and first win in the greater Bay Area — was Sonoma, where provisional ballots helped turn a narrow Clinton win into a Sanders win by more than 5,500 votes. Sonoma, the 17th-most populous county in California, was the most populous won by Sanders.

The senator did better in the congressional districts which actually decide delegate math. On election night, Sanders appeared to have carried just two of California's 53 districts; after Wednesday night, he won eight of them, including the Latino-heavy 34th district in Los Angeles, represented by key Clinton surrogate Rep. Xavier Becerra. The closest race was decided by just 67 votes in the 28th district, which covers the Los Angeles suburbs of Glendale and Burbank, and is represented by Rep. Adam Schiff.

Those victories cut into Clinton's delegate margin. On election night, the presumptive Democratic nominee appeared to net 63 delegates out of the state. The closer statewide margin and the divergent results in congressional districts cut that lead to 33 delegates — not significant enough to change the lead, but enough to send a few more Sanders supporters to California.

Also, in the end, Clinton's 2,745,293 votes set an all-time record for the California Democratic primary. Donald Trump's 1,665,126 votes were the most any Republican had won in the state's primary since the 2000 race between George W. Bush and Sen. John McCain.