[Sign up for California Today, our daily newsletter about the Golden State.]

State officials moved up the state’s primary to March this year in an attempt to make California more politically influential when it comes to choosing the Democratic presidential nominee. The change meant that voters saw far more television advertisements: roughly $120 million worth, with the majority coming from Mr. Bloomberg.

Several candidates visited parts of the state that have long been ignored in statewide elections, including Bakersfield and Riverside. Still, California never drew the candidates of early-voting states like Iowa or New Hampshire and most of the candidates relied on national news coverage to gain recognition in the state.

There was a clear generational split in the state, with Mr. Sanders winning among voters under 49, but Mr. Biden was the clear preference with voters older than 50. Mr. Biden won among older voters, black voters and moderates in California, the same coalition that helped him win several other states Tuesday. Mr. Sanders appeared to win among voters at all education levels, according to exit polls.

Mr. Sanders won more white and Asian-American voters, but reflecting a national trend, Mr. Biden took the lead among black voters, according to exit polls. Voters who chose a candidate in the final days sided with Mr. Biden by a 10-point margin, those polls showed.

In 2016, California proved to be something of a firewall for Hillary Clinton, who beat Mr. Sanders with 53 percent of the vote to his 46 percent. That year, the state voted in June, when the primary race was all but over.

This year it was Mr. Sanders who counted on California to be his own firewall. His campaign frequently referred to the “first five” states, lumping California with Iowa, New Hampshire, Nevada and South Carolina. In turn, the campaign poured significant resources into advertising and organizing in a state that has traditionally been viewed as impossible to penetrate by door knocking because of its vast size.

Mr. Sanders also held several large rallies in California, including one at Venice Beach in December with Representative Alexandria Ocasio-Cortez of New York, and several in the final days before Tuesday’s vote.