Police in New Brunswick confirmed early Friday that shooting suspect Justin Bourque has been arrested.

Mr. Bourque, 24, wanted in connection with the shooting deaths of three RCMP officers, was taken into custody shortly after midnight.

A Twitter message from New Brunswick RCMP finally brought some relief to the residents of this city, many of whom had been living in fear since the shootings took place Wednesday evening.

Story continues below advertisement

"Justin Bourque arrested by RCMP at 12:10 in Moncton He is in police custody. Residents of north Moncton can now leave their homes," the message said.

Police caught up with Mr. Bourque along Mecca Dr., roughly a kilometre from the trailer park where he lived and 800 meters from the tidy suburban streets where his rampage began.

An officer radioed "14alpha12, he's here on Mecca" shortly after the arrest, according to archived scanner audio at broadcastify.com.

Mecca Drive is an area of two-storey middle class homes where Mr. Bourque would have had a clear sight of residents as well as traffic on nearby Wheeler Blvd.

A Moncton resident named Michelle Thibodeau tweeted that she witnessed the arrest.

"He was in my backyard. I saw him arrested in front of my eyes. He is alive," Ms.Thibodeau tweeted.

"The swat team arrived at my house and unloaded and started screaming in my backyard for him to surrender and he did. I watched it happen.

Story continues below advertisement

"They had him sprawled on my front lawn for some time and then loaded him into the swat vehicle. They are now checking my yard for firearms."

At least six officers remained on the scene around 3 a.m. One woman out for a walk in the driving rain shortly after the arrest said she heard police yelling at the suspect before hearing him yelling "I'm done" just after midnight.

According to police, the suspect was spotted three times on Thursday but could not be apprehended. By afternoon, police snipers moved into position and officers surrounded a rooming house in Moncton. But after clearing the building, they left empty-handed. As night fell, the RCMP asked residents to stay locked in their homes and keep their porch lights on.

"This is working through your worst nightmare," RCMP Assistant Commissioner Roger Brown, the force's commanding officer in New Brunswick, said Thursday as the search was still underway. "This is a very, very dangerous situation."

Military-style armored vehicles patrolled the roads while helicopters whirred overhead. Tensions were high as police were grieving the loss of three colleagues, the worst mass shooting of police officers in Canada since the 2005 slaying of four officers at Mayerthorpe, Alta.

The officers in Moncton were gunned down in an ambush, police sources told The Globe and Mail.

Story continues below advertisement

One of the slain Mounties was Constable Dave Ross of the Codiac RCMP, according to several media reports. Constable Ross, a police dog handler, was married with a young son and another child on the way. His sister-in-law told The National Post that his widow came home to find the barbecue still running and Constable Ross gone, as he had been called to work urgently, likely after the first reports of a gunman at large. The RCMP did not immediately confirm the report and did not name the rest of the victims.

Two RCMP officers were also wounded during the gunfire. One was released from hospital on Thursday.

Mr. Bourque, who had no previous brushes with the law, was wearing military camouflage and carrying two high-powered rifles along with other weapons in a photo taken on Wednesday that police circulated. Witnesses who saw him shortly before the shooting described him as having a cold, blank look on his face. They said he carried an assault rifle, a shotgun and a crossbow, as well as several knives and ammunition belts. They also described him as a marksman who spent many hours at the gun range. It is not known whether his guns were bought legally.

As an eerie quiet settled over the city of 70,000, schools, government offices and public transit closed for the day. Police staffed roadblocks and checked cars for any sign of the suspect.

Residents of a large portion in the northwest part of Moncton, which includes a heavily wooded area, were ordered to stay inside and to lock their doors. Police appealed to citizens to report any sightings of Mr. Bourque or leads that may help identify his whereabouts.

"There's no question that we're going to continue this search in order to apprehend him at all costs," said Superintendent Marlene Snowman, commanding officer of the Greater Moncton RCMP. "And hopefully with no other injuries or deaths."

Story continues below advertisement

Danny Leblanc, 42, said he saw the shooter in the distance Wednesday evening, wearing a camouflage outfit and standing in the middle of the street with a gun pointed at police cars.

The construction worker said he believed it was an RCMP officer until he heard a burst of automatic gunfire coming from the man's gun.

"That guy was standing on the road afterward and he was looking toward us," he said.

He said he quickly retreated into his home with his family, adding a neighbour posted on social media that a kitchen window was shattered by gunfire.

Mr. Leblanc said few people on his normally quiet street were sleeping as they awaited word at midnight on whether arrests had been made.

"It's just crazy. We're chatting with our friends on Facebook and we're not going to bed until this guy is caught. I'm sure nobody in Moncton is sleeping because he seems to be all over the place," he said. The deaths of the three officers has shocked the city, he said.

Story continues below advertisement

"It's devastating. I don't know if he was on a hunt for them, or what," said Leblanc.

Helicopters whirred overhead overnight, the sound of police sirens and the light from passing armoured vehicles streamed into homes like that of Bill Daigle, who was outside doing lawn work with his wife when he heard what he first thought were fireworks but later proved gunfire just one block from his home.

He and his wife hardly slept since the lockdown set in Wednesday evening, their teenaged daughter returning home around 5 a.m. Thursday morning after staying the night at the local Superstore, where she works.

"We're nervous," Mr. Daigle said Thursday morning. "We'd be really happy to see this all resolved ... We know there's a very large police presence, so we trust that if we wait it out and stay inside, we'll probably be safe."

Mr. Daigle runs the city's Parlour Pawn Shop, and has worked closely with local RCMP for years to try to limit crime related to pawn sales. He said it's likely he knows the dead and wounded by first name; the names haven't yet been released.

He said it's likely the shooter travelled by foot from his Hildegard neighbourhood to the Pinehurst subdivision, where the search, playing out on his television, appears to be centred. It had been roughly a half-mile walk through a wooded area and across a major artery that runs through the small city, he said.

Story continues below advertisement

Prime Minister Stephen Harper, who is attending the G7 summit in Brussels, extended sympathies to the victims' families.

"I'd just like to express all of our sorrow at the deaths of the three members of the RCMP killed last night in New Brunswick in the performance of their duties," he told reporters. "This should obviously remind us that our men and women in law enforcement put their lives on the line every day to serve and protect us as Canadians and our thoughts and prayers are with the families of those killed and also the others wounded in this terrible incident."

Mayor George LeBlanc also offered his condolences to the families of the police officers who were killed and those who were injured.

"Never in my darkest dreams did I ever think that we would be facing what we're facing today in Moncton," he told reporters on Thursday.

New Brunswick Premier David Alward also passed on his sympathies to the victims' families.

"It just isn't possible to understand why such things happen but it is critical that as a community we work together to support the entire community at this time," he said.

Based on information from the RCMP's Honour Roll page on its website, the last Mountie to die from a gunshot was Const. Douglas Scott on Nov. 5, 2007. He was shot while responding to a call for help involving an impaired driver at Kimmirut, Nunavut.

The most recent police officer killed in the line of duty was Constable Steve Dery of the Kativik police force in northern Quebec. Constable Dery, 27, was shot and killed after he and another constable responded to a domestic violence call on March 2, 2013.

The shootings in Moncton brought back memories of an RCMP tragedy in Mayerthorpe, Alta., on March 3, 2005, when Constables Anthony Fitzgerald Orion Gordon, Lionide (Leo) Nicholas Johnston, Brock Warren Myrol and Peter Christopher Schiemann were shot and killed.

With reports from Josh O'Kane, Tu Thanh Ha, Jill Mahoney and The Canadian Press