Canadian police have arrested a man suspected of having shot dead three police officers and wounded two more, ending a massive manhunt.

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 armoured 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.

The 24-year-old had been named as a suspect late on Wednesday after the shootings.

Police said that Mr 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 yesterday. 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.

The picture could not be immediately authenticated.

A Facebook page purporting to belong to Mr 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.