Democrat Cathleen Galgiani and Republican Bill Berryhill will face off in November for the 5th Senate District seat.
The candidates, both members of the state Assembly, outpaced Republican Leroy Ornellas, a member of the San Joaquin County Board of Supervisors.
Galgiani came out on top with 38,547 votes, or 41.3 percent, with all the precincts reporting.
Berryhill had 33,504 votes, or 35.9 percent. Ornellas had 21,190 votes, or 22.7 percent.
"I'm pleased with the race that we've run, and I'm looking forward to a spirited debate in November," Galgiani said.
The district includes all of San Joaquin County; most of Modesto and the Salida, Riverbank and Empire areas; and a small piece of Sacramento County.