HALF MOON BAY, Calif. — A gunman killed seven people in two locations in Half Moon Bay, Calif., on Monday, shaking a state still mourning another mass shooting just days before.

The police arrested Zhao Chunli, age 67, of Half Moon Bay in connection with the shootings after he was found in his car in the parking lot of a San Mateo County Sheriff’s Office substation in the town, the sheriff’s office said, and there was no continuing threat to the community.

He was taken into custody “without incident” and was “fully cooperating,” Sheriff Christina Corpus said. Investigators believe he acted alone, she said.

Investigators have not established a motive, according to Capt. Eamonn Allen of the sheriff’s department. The local authorities were working with the F.B.I. and had not uncovered a criminal history or past incidents at either of the scenes, he said.

Gov. Gavin Newsom of California wrote on Twitter that as news of the shooting broke, he had been at a hospital, meeting victims of a mass shooting on Saturday in Monterey Park. In that attack, a gunman fatally shot 11 people.

“Tragedy upon tragedy,” Gov. Newsom said.

Monday’s shootings took place around 2:20 p.m. in Half Moon Bay, a rural seaside town between San Francisco and Santa Cruz. The beaches are a popular surfing destination, and the inland mountains are home to one of the state’s oldest agricultural communities, which employs migrant workers.

At least one of the two locations was a plant nursery, the sheriff’s office said.

“There were farmworkers affected tonight. There were children on the scene at the incidents. This is a truly heartbreaking tragedy in our community,” San Mateo County Supervisor Ray Mueller said in a news conference, where he alluded to the storms that have pounded the area in recent weeks. “The amount of stress that’s been on this community for weeks is really quite high.”

Four people were found dead at a location near Highway 92, and a fifth person with life-threatening injuries was taken from that site to Stanford Medical Center, according to the sheriff’s office. Three more people were found dead about a mile away, on the outskirts of the city.

The sheriff’s office said late Monday that it was working to identify the victims and notify their families. All the victims were adults, but some workers lived at the location of one of the shootings along with children, Sheriff Corpus said.

“It was in the afternoon, when kids were out of school,” she said. “For children to witness this is unspeakable.”

No connection between the two locations was immediately known. Sheriff Corpus said the police believed the suspect was a worker at the plant nursery where one of the attacks occurred. The gunman drove from one site to the other, she said, and a semiautomatic handgun was found in his vehicle.

Video of the substation parking lot where the suspect was arrested shows three police officers pulling him from a maroon S.U.V. They then pushed him to the ground and handcuffed him as he lay there.

The suspect spoke Mandarin and had difficulty with English, the sheriff’s office said. Investigators brought in a detective who speaks Mandarin to interview him, Capt. Allen said.

Throughout the afternoon, a nonprofit group took people by van from a crime scene to a family reunification center at the I.D.E.S. Portuguese Hall, a community center run by a religious society in downtown Half Moon Bay.

About 40 people were sheltering there on Monday evening. Among them were older people and children, including one playing with a German shepherd police dog.

Though the identities of the victims were not known, at least one of the shooting scenes was an agricultural site, where workers also lived.

Lorena González Fletcher, president of the California Labor Federation, said that many farmworkers in the region were in a vulnerable position because they have low wages and are often on temporary work visas or are undocumented. The United Farm Workers labor union has provided emergency aid in the area after the recent floods, she added.

“It’s heartbreaking to think about the families torn apart just trying to live their lives,” said Elizabeth Strater, director of strategic campaigns for the union.

At the community center, workers associated with the group who had transported people there were speaking in Spanish with some of the families, while another nonprofit organization coordinated supplies. A volunteer asked a police officer standing guard at the door what size diapers they needed.

Sarah Prentice, 31, started crying while on her way to the center to drop off blankets. “You don’t really expect these things to happen in your hometown. And I guarantee that someone I know knows someone who was killed. That’s the kind of community it is. It’s small.”