A man disguised as a police officer went on a shooting rampage in the Canadian province of Nova Scotia on Sunday, killing at least 18 people, in the worst such attack in the country in 30 years.

A police officer was among those killed. Several bodies were found inside and outside one home in the small, rural town of Portapique, about 100km (60 miles) north of Halifax - what police called the first scene.

More:

Bodies were also found at other locations and buildings set on fire. The suspected gunman is also dead.

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

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 wounded.

An undated photograph of a police cruiser, altered by the RCMP to point out the car's unique number, is shown in an appeal to the public after they say multiple-victim shooting suspect Gabriel Wortman could be driving the car and wearing an RCMP uniform near Portapique [RCMP Nova Scotia/Handout via Reuters]

Police identified the man believed to be the shooter as Gabriel Wortman, 51, who was thought to live part of the time in Portapique. Authorities said he wore a police uniform at one point and made his car look like a RCMP vehicle.

Authorities believe he may have deliberately singled out his first victims before he began attacking randomly. Police said they had no indication of a motive and the killer had acted alone.

"The search for the suspect ended this morning when the suspect was located and I can confirm that he is deceased," RCMP Chief Superintendent Chris Leather told a press conference.

Leather said the gunman had exchanged fire with police at one point.

"Our officers were involved in terminating the threat," he said, adding the independent Serious Incident Response Team (SiRT), which probes incidents involving the province's police, was now handling that part of the investigation.

SiRT said in a statement a confrontation had occurred in Enfield, which is near Halifax airport, "resulting in officers discharging their firearms. The suspect was found to be deceased at the scene".

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-coloured four-wheel drive was being investigated.

Mass shootings are relatively rare in Canada. The country overhauled its gun-control laws after its worst mass shooting in 1989, when gunman Marc Lepine killed 14 women and himself at Montreal’s Ecole Polytechnique college.

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

"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 statement.

The National Post newspaper quoted Tom Taggart, a councilor who represents Portapique in the Municipality of Colchester, as saying the community was devastated.

He described the community as a "subdivision in the woods where people have acre lots along the shore", and where Wortman owned three properties.

"It's absolutely unbelievable this could happen in our community. I never dreamt this would happen here," Taggart said.