Police officers arrive with primary ballots to be counted Tuesday at the Citywide Senior Center in Central Square. (Photo: Marc Levy)

The state primaries held Tuesday showed Cambridge voters bucking some statewide trends, with the most striking on the Democratic side being the popularity of secretary of state candidate Tanisha Sullivan in her run against seven-term incumbent William Francis Galvin. Cantabrigians Republicans also opted decisively for a gubernatorial candidate condemned by former president Donald Trump, while Republicans statewide chose the one Trump endorsed.

There were many uncontested primary candidates Tuesday, including all local state senators and representatives running for reelection, who are also all Democrats;Democratic U.S. Reps. Katherine Clark and Ayanna Pressley and Republican U.S. Reps. Caroline Colarusso and Donnie Palmer; Middlesex County district attorney Marian Ryan and county sheriff Peter Koutoujian; Democratic Governor’s Council member Terrence Kennedy; and Democratic gubernatorial candidate Maura Healey, who is expected to go on to replace Republican Gov. Charlie Baker and become the first female and openly gay leader of the state.

Many of the races’ outcomes were nearly as predictable, such as Galvin keeping the office he has held since 1995.

But not in Cambridge.

Preliminary results released by the Election Commission late Tuesday showed there were 15,916 ballots cast out of 69,189 registered voters, for a 23 percent turnout, with and 15,094 of those being Democratic ballots, and only 822 being Republican. That means that of the 23 percent of the electorate voting, 22 percent was Democratic. (Statewide, around 32 percent of voters identify as Democratic and nearly 10 percent identify as Republican.) Statewide figures are taken from the latest reporting by media sources such as The Associated Press, Boston.com and The New York Times.

While statewide Galvin cruised to victory Tuesday with 72 percent of ballots to Sullivan’s 28 percent, leading the Boston challenger to concede, she was far more competitive in Cambridge and made for a far tighter run: Here she had 7,310 votes (out of 14,647 cast in this race) for 49.91 percent of the electorate to Galvin’s 7,329 votes and 50.04 percent.

GOP for governor, Dem auditor

In the Republican race for gubernatorial candidates, the opponents were Geoff Diehl, a Trump candidate and former state representative from Whitman, and Chris Doughty, a Wrentham business owner who at least stood a better chance of inheriting Baker’s seat to become another in a long line of Republican governors in a Democratic-leaning state.

But by the time the race was called Tuesday, the Trump candidate had 56 percent of the statewide vote to Doughty’s 44 percent – and will surely go down to defeat as he did running against U.S. Sen. Elizabeth Warren of Cambridge in 2018, when she trounced him by 24 points.

Maybe Republicans statewide would have been better off listening to Cambridge Republicans. Preliminary results from the Election Commission show Doughty winning with 461 votes from 816 ballots here, or 57 percent. Diehl had 353 votes, or 43 percent.

Republican gubernatorial candidate Geoff Diehl gives a sense of his support Tuesday in Abington in a photo shared on social media by his campaign. (Photo: Geoff Diehl via Facebook)

That dynamic repeated for the Republican lieutenant governor candidates: Statewide, Diehl’s unofficial running mate Leah Allen took 52 percent of the vote, while Doughty’s co-campaigner, Kate Campanale, lagged at 48 percent. In Cambridge, it was Campanale ahead with 428 votes out of 754 ballots, or 58 percent; the loser here was Allen, with 322 votes totaling 43 percent.

In the Democratic auditor race it was another Cambridge upset with Christopher Dempsey – who led a successful 2015 campaign against bringing the Olympics to Boston – beating Diana Dizoglio soundly with 59 percent to her 41 percent. Yet statewide the results were the opposite, with Dizoglio taking 54 percent statewide to Dempsey’s 46 percent.

Where Cambridge aligned

In other races, Cambridge’s selections were a closer match for the state’s mood.

For the three-way run for Democratic lieutenant governor, Kimberley Driscoll had 47 percent of the vote to Eric Lesser’s 33 percent and Tami Gouveia’s 20 percent. In Cambridge those figures were Driscoll with 46 percent; Gouveia with 28 percent; and Lesser with 27 percent.

For attorney general – the Democratic winner will take the seat Healey leaves to run for governor – Andrea Campbell beat Shannon Liss-Riordan to become the first black woman in Massachusetts history winning a Democratic nomination for statewide office. Statewide, Campbell had 51 percent of the vote to Liss-Riordan’s 34 percent. In Cambridge, Campbell had 61 percent to Liss-Riordan’s 26 percent.

For the Governor’s Council run between Democrats Marilyn Devaney and Mara Dolan, the percentage results were essentially identical for the state and Cambridge: Devaney edged out Dolan by 51 percent of the vote to 49 percent.