TORONTO -- A shooting in a small Canadian city early Friday left four people dead, including two police officers, under circumstances that were not yet explained but struck a nerve in a country that has been roiled in recent months by several instances of mass violence. People in Fredericton, the capital of New Brunswick in the eastern part of the country, said they heard as many as 20 gunshots following a confrontation that prompted police to initially cordon off a large section of the city with emergency vehicles and order residents to remain inside their homes and businesses.

Finally, after a tense period of waiting, authorities disclosed the toll: Among the four killed were two officers, a rare case of police killed in the line of duty in Canada. Their names were not released.

Of the four people killed in this morning's shootings on Brookside Drive, two were Fredericton Police officers. No names are being released at this time. Please appreciate this is a difficult time for their families and our colleagues. We will provide more info when we can. — Fredericton Police (@CityFredPolice) August 10, 2018

Authorities said one suspect was in custody and was being treated for serious injuries. The person's identity was not announced and no motive was disclosed. A news conference was planned for later Friday.

We can confirm that the suspect in custody is currently being treated for serious injuries related to this morning’s shooting incident. — Fredericton Police (@CityFredPolice) August 10, 2018

Several other victims were being treated at a regional hospital, but there were no immediate details on the nature of their injuries or their conditions.

Get Breaking News Delivered to Your Inbox

"Our hearts are broken by the murder of our two brave police officers," Fredericton Mayor Mike O'Brien said in a tweet.

The entire province of New Brunswick had 11 homicides in 2016.

In Fredericton, a city of about 60,000 residents, people said they were stunned by the scene, which occurred as people were heading to work or dropping children at a day care center not far from the apartment complex where the shooting took place. "This is the first time I've even heard of any serious crime or violent crime in this city," said Travis Hrubeniuk, whose fiancee had just left their home when the sirens began.

Rachel LeBlanc, who sheltered at a daycare center in the lockdown area on Brookside Drive, told CBC she heard gunshots shortly after arriving there for work on Friday. She said she heard a "crack, crack, crack, four in a row" in rapid succession. LeBlanc told CBC that the 23 kids in her care were unaware of the security incident, but that she was nervous as the person in charge of their care.

Bill Henwood, a funeral director at York Funeral Home, whose business is located inside the cordoned off area on Brookside Drive, said people sat in their cars or were just standing near the blockade of police and fire vehicles "hanging tight and waiting for word" for news.

"It's not something that we expect in Fredericton to wake up and hear about," Henwood said. "To see that there's actually fatalities is pretty extraordinary for this area."

The shooting comes as Canada wrestles with a string of violence, including an instance in Toronto last month where a man with a handgun opened fire in a crowded part of the city, killing two people and wounding 13 before he either shot himself or was killed by police.

In April, a man who linked himself to a misogynistic online community used a van to run down pedestrians in a busy part of Toronto, killing 10 people and injuring 14.

Authorities are still pursuing leads in an ongoing investigation of a serial killer who has been charged with killing eight men in the city in recent years.

In 2014, a shooting in Moncton, New Brunswick left three Royal Canadian Mounted Police officers dead and two wounded.There was no immediate information on any suspected motive in the shooting, and no information provided on the identities of the suspect in custody or the victims.

David MacCoubrey, who lives in Fredericton, said he heard about 20 shots fired. He was hiding on his kitchen floor. He awoke in his apartment on Brookside Drive around 7 a.m. local time to the sound of three gunshots about 30 feet from his bed.

MacCoubrey said his apartment complex has four buildings in a square, and it sounded like the shots were coming from the middle of the complex. He said police searched the complex, including his own apartment.