Two police officers were among the four people shot and killed Friday morning in the Canadian city of Fredericton, New Brunswick, police said.

The suspect taken into custody has been identified as Matthew Vincent Raymond, 48. He was charged with four counts of first-degree murder at an arraignment Saturday morning, the Globe and Mail reported. Raymond was hospitalized with gunshot wounds after a confrontation with police, authorities said.

The suspect is due to appear in court Aug. 27, the report said.

The slain officers were identified as Sara Mae Helen Burns, 43, and Lawrence Robert Costello, 45, officials said during a news conference.

Burns had been on the force for two years before previously serving as an auxiliary officer for another two years, police said. She leaves behind a husband and three children.

Costello was a 20-year veteran of the police department and leaves behind a partner and four children, police said.

On Saturday, authorities identified the two slain civilians as Donald Robichaud, 42, and Bobbie Lee Wright, 32. A Facebook post by Wright earlier this month said the pair were in a romantic relationship, the Globe and Mail reported.

Fredericton police responded to calls of shots fired around 7:10 a.m., Deputy Police Chief Martin Gaudet said. After arriving to the scene, officers saw two civilian victims on the ground before getting shot themselves.

Earlier Friday morning officials tweeted to caution residents to avoid Brookside Drive due to an "ongoing incident." Later, police confirmed four people had been killed. It was not immediately clear what caused the shooting.

Police urged residents to stay in their homes and lock their doors at the time of the incident.

Residents told CBC News the gunshots sounded like popping noises.

"With the tempo, it might've been a gunshot. It was sort of like a pop, pop, pop, pop," resident Robert Didiodato told CBC News.

Didiodato said people were staying inside their homes and following the department's instructions.

CTV News spoke to a woman who was escorted from her residence in the area and she told the station she heard what appeared to be gunshots. The media outlet reported police were talking to residents in the area asking what they heard or witnessed.

David MacCoubrey, who lives in Fredericton, said he heard about 20 shots and was hiding on his kitchen floor.

"I'm on my floor," he told the Associated Press in a phone interview. "The cops have come through my place. They have searched all the apartments in the building. It sounded like it started in the courtyard area."

MacCoubrey said police have been searching the buildings, and he’s been sitting away from windows.

Travis Hrubeniuk said his fiancée had just left for work around 7:45 a.m. local time when he began hearing a steady stream of sirens.

Hrubeniuk said residents have been advised to stay inside with their doors locked. The quiet residential neighborhood, which has houses, grocery stores, a church and an elementary school, is the last place Hrubeniuk said he expected to encounter a dangerous situation.

"This is the first time I've even heard of any serious crime or violent crime in this city," he said.

Canadian Prime Minister Justin Trudeau tweeted his condolences following the incident.

"Awful news coming out of Fredericton. My heart goes out to everyone affected by this morning's shooting. We're following the situation closely," the prime minister wrote.

Fredericton has a population of about 58,000 and is located just northeast of Maine. The city is the capital of New Brunswick.

Fox News' Elizabeth Zwirz and the Associated Press contributed to this report.