TORONTO — Canadian police charged a man Saturday for the deaths of two police officers and two civilians in a shooting that struck a nerve in a country that has been roiled in recent months by several instances of mass violence.

Police in the eastern city of Fredericton, New Brunswick, said that Matthew Vincent Raymond, 48, was arrested and charged with four counts of first-degree murder.

Horizon Health, which delivers care for New Brunswick’s Department of Health, said that Raymond was the only person being treated for injuries related to the shooting. He is due to appear in court on Aug. 27.

The victims have been identified as police Constable Robb Costello, 45, police Constable Sara Burns, 43, Donnie Robichaud, 42, and Bobbie-Lee Wright, 32.

Robichaud and Wright were in a relationship, according to Facebook and Robichaud’s cousin, Sean Callahan, who said they had just gotten together at the beginning of August.

No motive has been disclosed, and police said they were working to determine a link between the gunman and the couple.

Police said Costello and Burns were responding to calls of shots fired at an apartment complex and saw two deceased civilians before being shot and killed themselves.

Fredericton Police Chief Leanne Fitch said Raymond used a long gun and was in an elevated position when he fired. Fitch said he was shot by police and was in serious but stable condition.

Fredericton residents were stunned by the episode, which took place in a city of 60,000 that last saw a homicide in 2014.