The shooting in the eastern city of Moncton was one of the worst of its kind in Canada, where gun laws are stricter than in the US and deadly attacks on police are rare.
"Justin Bourque arrested by RCMP at 12:10 in Moncton," the Royal Canadian Mounted Police said in a tweet. "He is in police custody. Residents of north Moncton can now leave their homes."
Schools and government offices had been shut in the city of about 70,000 in the East Coast province of New Brunswick.
Hundreds of police, some in armoured vehicles, had cordoned off a large area in the city on Thursday and warned residents to stay at home and lock their doors.
Bourque, 24, had been named as a suspect late on Wednesday after the shootings, with police saying he had since been spotted several times in Moncton. RCMP Superintendent Marlene Snowman said he had no previous criminal record.
Police were alerted on Wednesday afternoon by a member of the public who spotted an armed man in camouflage clothing walking down a residential street. When police arrived, the man moved into a nearby wooded area and opened fire.
Three officers were killed and two more were taken to hospital, where both had surgery on Thursday. One of the two was later released.
Canadian media published a photograph of a man wearing camouflage clothing and a black headband and carrying a rifle. A Facebook page purporting to belong to Bourque was filled with posts critical of the police and those who back gun control.
The killings spurred an outpouring of grief across Canada.The last mass killing of police took place in Mayerthorpe in the western province of Alberta in 2005, when a gunman killed four officers before shooting himself. Those killings were the most the RCMP had suffered in a single day in 100 years.