Ottawa: Two police officers were among four people killed on Friday in a shooting that sparked panic and a police lockdown in a sleepy eastern Canadian city, as the nation grapples with rising gun violence.

Residents of the Brookside neighborhood of Fredericton, New Brunswick reported waking to the sounds of multiple gunshots.

Witnesses described to the Canadian Broadcasting Corporation (CBC) seeing the barrel of a rifle or shotgun poking out from the window of a low-rise apartment building and firing into a courtyard, while two bodies lay on the ground nearby.

Heavily-armed police, paramedics and firefighters quickly descended on the scene and a lockdown of the neighborhood was ordered, trapping some early risers in daycare facilities, coffee shops and businesses.

Others were escorted from their homes - some still in pyjamas and barefoot - to safety beyond a police cordon.

Fredericton Deputy Police Chief Martin Gaudet told reporters the two officers killed were responding to an emergency call about gunshots. 

"Upon arrival (at the apartment building), they observed two civilian victims on the ground. That's when they (police) were shot," Gaudet said.

Authorities in the provincial capital, about 75 kilometres from the border between Canada and the US state of Maine, had initially urged people in the neighborhood to stay indoors.

They described an "active incident" on Twitter before confirming the deaths and arrest. The suspect was being treated for "serious injuries" related to the shooting incident, police said.

Gaudet said police entered the shooter's apartment in the residential area of the city north of downtown, and arrested a 48-year-old man. No other information was provided about the suspect or the events.

"It's been a very difficult day for our officers and the residents of our fine city as we come to terms with the violent death of four of our people in our city, two of which, as you know are officers," said Police Chief Leanne Fitch.
'Gun pointing out of window' 
Public broadcaster CBC quoted Justin McLean, who lives in the area, as saying: "I woke up and I heard gunshots and I looked outside my window.

"The cops were trying to put one of the officers in their vehicle to take them out to safety," he said, adding that he tried to help but was told by the officers to take cover.

"I never saw the shooter but I saw the barrel of his gun pointing out of the window."

The mass shooting is the second in the province in recent years, and comes only weeks after a man opened fire on July 22 in a bustling Toronto district, killing an 18-year-old woman and a 10-year-old girl while wounding 13 other people.

The incident triggered a public debate on rising gun violence and gangs in Canadian cities, and calls for a handgun ban.

"Most crime rates (in Canada) are going down and have been going down for several decades. But the incidents of violence with firearms have been going up over the course of the last five years," Public Safety Minister Ralph Goodale said.

He said local police would be leading the investigation, suggesting there was no concern for national security.

"Awful news coming out of Fredericton," Prime Minister Justin Trudeau tweeted.
"My heart goes out to everyone affected by this morning's shooting."

Bouquets of flowers and notes of condolences amassed outside the Fredericton police station, while a local church scheduled a prayer vigil for Friday evening.

In 2014, three federal police officers were killed and two more were injured after responding to an emergency call about an armed man roaming a residential neighborhood of nearby Moncton, New Brunswick.

A 28-hour manhunt ensued before police caught up to the suspect and arrested him, in what was described as the second-deadliest attack on Canadian police since four Royal Canadian Mounted Police officers were ambushed on a Mayerthorpe, Alberta farm in 2005.