A gunman disguised as a police officer went on a rampage across the Canadian province of Nova Scotia, shooting people in their homes and setting fires, leaving 16 people dead Sunday, in the deadliest such attack in the country’s history. Officials said the suspected shooter was also dead.

A police officer was among those killed. Several bodies were found inside and outside one home in the small, rural town of Portapique, about 60 miles north of Halifax — what police called the first scene. Bodies were also found at other locations.

Overnight, police began advising residents of the town — already on lockdown because of the coronavirus pandemic — to lock their doors and stay in their basements. Several homes in the area were set on fire as well.

Police identified the man believed to be the shooter as Gabriel Wortman, 51, who was thought to live part-time in Portapique. Authorities said he wore a police uniform at one point and made his car look like a Royal Canadian Mounted Police cruiser. Authorities believe he may have targeted his first victims but then began attacking randomly.

Police first announced that they had arrested Wortman at a gas station in Enfield, outside Halifax, but later said he had died. It was not clear how, and they did not explain further.

“This is one of the most senseless acts of violence in our province’s history,” said Nova Scotia Premier Stephen McNeil.

RCMP spokesman Daniel Brien confirmed that 16 people had been killed in addition to the suspect. The dead officer was identified as Constable Heidi Stevenson, a mother of two and a 23-year veteran of the force. Another officer was also injured.

Mass shootings are relatively rare in the country. Canada overhauled its gun-control laws after a 1989 mass shooting in which gunman Marc Lepine killed 14 women and himself at Montreal’s Ecole Polytechnique college. Before this weekend's rampage, that had been the country's worst.

It is now illegal to possess an unregistered handgun or any kind of rapid-fire weapon in Canada. The country also requires training, a personal risk assessment, two references, spousal notification and criminal record checks to purchase a weapon.

“As a country, in moments like these, we come together to support one another. Together we will mourn with the families of the victims, and help them get through this difficult time,” Prime Minister Justin Trudeau said in a written statement.

While they believe the attack did not begin as random, police did not say what the initial motive was. RCMP Chief Superintendent Chris Leather said many of the victims did not know the shooter.

“That fact that this individual had a uniform and a police car at his disposal certainly speaks to it not being a random act,” Leather said. He added that police believe he acted alone.

Leather said they would investigate whether the attack had anything to do with the coronavirus pandemic but no link has been found thus far.

At one point, there was an exchange of gunfire between the suspect and police, he said.

Late Sunday morning, there were half a dozen police vehicles at the scene of the gas station where the suspect died. Yellow police tape surrounded the gas pumps, and a large silver-colored SUV was being investigated.

Cpl. Lisa Croteau, a spokeswoman with the provincial force, said police received a call about “a person with firearms” late Saturday night, and the investigation “evolved into an active shooting investigation.”

Christine Mills, a resident of the area, said it had been a frightening night for the small town, with armed officers patrolling the streets. In the morning, helicopters flew overhead searching for the suspect. “It’s nerve-wracking because you don’t know if somebody has lost their mind and is going to beat in your front door," she said.

Tom Taggart, a lawmaker who represents the Portapique area in the Municipality of Colchester, said the quiet community has been shaken.

“This is just an absolutely wonderful, peaceful quiet community and the idea that this could happen in our community is unbelievable,” Taggart said by phone from his home in nearby Bass River.

A Gabriel Wortman is listed as a denturist — a person who makes dentures — in the city of Dartmouth, near Halifax, according to the Denturist Society of Nova Scotia website. A suspect photo issued by the RCMP appears to be of the same person seen in video footage being interviewed about dentures by CTV Atlantic in 2014.

Mills also said that Wortman was known locally as someone who divided his time between a residence in Halifax and a residence in Portapique.

Taggart said he didn’t know Wortman well, but spoke to him a few times when he telephoned about municipal issues.

Taggart described knowing Wortman’s “lovely big home” on Portapique Beach Road.