Canadian police have arrested a man suspected to have shot dead three police officers and wounded two more, ending a massive manhunt, the police said on Friday.

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 United States 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 armored vehicles and some with dogs, had cordoned off a large area in the city on Thursday and warned residents to stay in their homes and lock their doors.

Bourque, 24, had been named as a suspect late on Wednesday after the shootings, with police saying that Bourque, who had no previous criminal record, had since been spotted several times in Moncton.

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. Reuters could not immediately authenticate the picture.

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.