A gunman disguised as a policeman killed at least 16 people, including a female police officer, in what is believed to be Canada’s worst mass shooting.

The 12-hour rampage started on Saturday and ended with a car chase.

Police said the suspect shot people at different locations in Nova Scotia, many of them randomly. He was killed in a confrontation with police.

He was reported to have been driving what looked like a police car.

Residents had been advised to lock themselves indoors the rural town of Portapique after the attack began.

Authorities were still trying to establish the final death toll on Sunday. They warned that there may be more victims.

Royal Canadian Mounted Police Constable (RCMP) Heidi Stevenson, who had served in the force for 23 years, was among those killed.

“Heidi answered the call of duty and lost her life while protecting those she served,” Nova Scotia RCMP Commanding Officer, Assistant Commissioner Lee Bergerman said in a Facebook post.

“Two children have lost their mother and a husband his wife. Parents lost their daughter and countless others lost an incredible friend and colleague,” Commissioner Bergerman said.

RCMP Commissioner Brenda Lucki said she believed the gunman had an initial “motivation” at the beginning that “turned to randomness”, according to CBC News.

Canadian Prime Minister Justin Trudeau described it as “a terrible situation” and Nova Scotia Premier Stephen McNeil told reporters “this is one of the most senseless acts of violence in our province’s history.”

Police say they were first alerted to an incident involving firearms late on Saturday.

Tweets by Nova Scotia police identified the alleged attacker as 51-year-old Gabriel Wortman.

He was not employed by the Royal Canadian Mounted Police but “maybe wearing an RCMP uniform”, they said.

“There’s one difference between his car and our Royal Canadian Mounted Police vehicles: the car # [registration plate]. The suspect’s car is 28B11, behind rear passenger window. If you see 28B11 call 911 immediately,” they tweeted on Sunday.

The gunman later changed cars to drive a “small silver Chevrolet SUV”, police added.

The police provided few details about how the suspected gunman died.

Mass shootings are relatively rare in Canada where gun ownership laws are stricter than in the neighbouring United States.

Last year two fugitive teenagers confessed to killing three people, including an Australian-US couple on holiday, in northern British Columbia.

In 2017, university student Alexandre Bissonnette shot dead six worshippers and injured either others a Quebec City mosque.

The Royal Canadian Mounted Police have been targeted in a number of shootings, including an attack that left three officers dead in Moncton, New Brunswick, in 2014.

In 1989, a college shooting in Quebec left 14 women dead after the killer sent all the men out of the classroom and opened fire.