Canadian police arrested Justin Bourque suspected of killing three officers and wounding two others in Moncton, New Brunswick.
The Royal Canadian Mounted Police in New Brunswick tweeted that Justin Bourque was arrested just after midnight in Moncton.
News of the arrest came after a huge manhunt went into its second night.
Schools and government offices were closed and residents told to stay indoors during the operation.
Police said residents of Moncton could now leave their homes.
A grainy image purporting to show Justin Bourque being taken into custody was circulating on social media.
The mayor of Moncton, George Leblanc, told CBC: “On the one hand we feel very happy, almost elated that this person has been arrested and this ordeal is over.
“But at the same time we have a great sense of sadness for the losses that our families have suffered.”
Earlier, police said the suspect, who was wearing camouflage gear and carrying rifles, had been spotted several times in north Moncton.
Dozens of police officers were seen scouring the search area with weapons drawn. Armoured security trucks were also visible.
One of the wounded Royal Canadian Mounted Police (RCMP) officers has been released from hospital, and one remains in hospital in a stable condition.
The officers were shot while responding to a report of an armed man at the north-west side of the town at about 20:00 local time on Wednesday.
It was the deadliest attack on Canada’s police force since four officers were killed by a gunman on a farm in the western province of Alberta in 2005.
[youtube Mm_fLZiBI1Y 650]