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.

(Read The Globe's latest on the Moncton shooting here, and see our complete coverage in one place here.)

Story continues below advertisement

Barricades that had been in place while police scoured the city of Moncton started coming down immediately after word of the arrest began to leak.

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.

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

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.

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

Story continues below advertisement

Businesses and schools had been shut down for nearly 30 hours as hundreds of police hunted a man described as a gun enthusiast whose Facebook page included anti-police slogans, was believed to be carrying several weapons and plenty of ammunition.

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 to help with visibility.

"This is working through your worst nightmare," said RCMP Assistant Commissioner Roger Brown, the force's commanding officer in New Brunswick. "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.

One of the slain Mounties was Constable Dave Ross of the Codiac RCMP, according to a report in The National Post. Constable Ross was described as a police dog handler who was married with a young son and with another child on the way. His sister-in-law told the paper 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.

Story continues below advertisement

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

The shootings began after a woman called 911 to report that a man carrying guns was walking along a road on Wednesday evening, Supt. Snowman said. The officers who were shot at included those who were first on the scene as well as their colleagues who were summoned to provide back up, she said.

Story continues below advertisement

Vanessa Bernatchez was enjoying a few drinks in her family's backyard when a neighbour yelled at them to get inside.

"There's a man outside," she recalls the neighbour saying. "He's shooting cops."

Moments later they heard gunshots and ran inside, locking the doors behind them. From inside the house they peeked out the front windows and noticed other neighbours milling around.

"We yelled at them 'get in the house, get in the house,'" she said.

She decided she had to alert friends in the area about the man with the guns, so she started recording a short video that she intended to send out through social media as a warning to stay away. She had no idea it would eventually get replayed by news outlets around the world.

That's when an unmarked police car rolled up and a plainclothes police officer stepped out. He was wearing a flak vest. Ms. Bernatchez said he kept turning around because he didn't know the direction of the shooter. That's when family members noticed a shadow growing larger between two houses next door.

Story continues below advertisement

"We knew it was the shooter right away," she said. "We banged on the windows to let the officer know. We yelled 'turn around.' Then there was a shot. The officer went down. He got shot in the neck."

Despite his mortal wound, the officer managed to squeeze off two shots from his handgun as he fell to the ground, according to Ms. Bernatchez.

"He was still trying to get that shooter, but as soon as he hit the ground, he stopped moving."

For Ms. Bernatchez, the most chilling part was still to come. They saw the shooter clearly. He was wearing a hat and had dark smudges beneath his eyes. The family watched through the front window as the shooter calmly raised his rifle and walked away slowly.

"He just walked away as if it was no big deal," she said. "That's what made me sick to my stomach."

Ms. Bernatchez ran to the phone and called 911. She gave her location and the officer's condition. The operator suggested the officer could be playing dead.

Story continues below advertisement

"I said 'No, there's too much blood. He's not moving.'"

Within 10 minutes, her street was flooded with police.

"We told them he went toward the woods and the highway. We've been in the house ever since. I haven't slept."

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.

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

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 The Canadian Press