(CNN) -- The U.S. Border Patrol agent killed Tuesday night in Arizona was shot after he confronted a group of bandits believed to be preying on illegal immigrants in the desert north of the border, the head of the Border Patrol union said Wednesday.

The FBI and the Santa Cruz County Sheriff's Office, which are jointly investigating the shooting, have provided scant details of the circumstances leading up to the shooting.

But T.J. Bonner, president of the National Border Patrol Council, said Brian A. Terry was operating as part of a tactical unit conducting surveillance for bandits when they encountered a group of five people and a gunfight broke out.

"They had received information about bandit activity in that area," Bonner said. "It's an area that is notorious for that, despite the fact it is so far from the border. I think it was about 18 miles from the border."

FBI Special Agent Manuel J. Johnson said agents were patrolling a very remote and rugged area north of the border town of Nogales when they encountered several armed individuals. Initial information shows there was an exchange of gunfire, he said.

Terry was shot and later died, Johnson said. Four men were apprehended and one of the captured suspects was taken to a hospital with a gunshot wound. Authorities are searching for a fifth man, he said.

Bonner said "border bandits" typically prey on illegal immigrants in the area, accosting them with guns and stealing whatever money or possessions they have.

"The border is not secure," Bonner said. "Those who say that it's secure are either misinformed or they're being disingenuous. If you have bandits operating that far north into the United States and there's enough activity to sustain that (criminal enterprise), it tells you there's a lot of traffic getting by the Border Patrol."

Calling it "a real tragedy any time you lose a law enforcement officer in the line of duty," Bonner said, "There are men and women who go out and risk their lives every night. It never gets easy and it seems to get harder every time you lose another brother from law enforcement."

Terry, a native of Detroit had served 3 1/2 years in the Border Patrol and four years in the military, Bonner said.

"Our thoughts and prayers are with the Terry family for their tragic loss," said Customs and Border Protection Commissioner Alan Bersin. "Our commitment to Agent Terry and his family is that we will do everything possible to bring to justice those responsible for this despicable act."

"The fatal shooting of Border Patrol Agent Brian A. Terry last night is an unconscionable act of violence against the men and women of the Border Patrol and all those who serve and defend our country," Homeland Security Secretary Janet Napolitano -- the former governor of Arizona -- said in a statement.

She said Terry's death "is a stark reminder of the very real dangers our men and women on the front lines confront every day as they protect our communities and the American people."

She said authorities "will leave no stone unturned as we seek justice for the perpetrators" and offered her condolences to Terry's family.

Gov. Jan Brewer ordered flags to be flown at half-staff to honor Terry. Brewer said Terry is survived by his parents, a brother and two sisters.

"Our prayers are with his family, as well as all Border Patrol agents and their families," Brewer said.

Terry is the third Border Patrol agent to be killed in the line of duty this year, the Customs and Border Protection agency says. Thirty-four agents have died in the line of duty in the past 15 years, according to agency figures.

In August, President Obama signed a bill that provides $600 million in emergency funding to help secure the U.S.-Mexico border. Among other things, the bill provides for roughly 1,500 new law enforcement agents, new unmanned aerial vehicles, new forwarding operating bases and $14 million in new communications equipment.

More than 520 National Guard and Army troops were recently assigned to the Arizona-Mexico border through the bill. Federal officials said in July that human smuggling and illegal border crossings were on the rise in the Tucson, Arizona, sector of the border.

Monday, Immigration and Customs Enforcement agents discovered a cross-border smuggling tunnel in Nogales after seizing more than 2,100 pounds of marijuana that was rolled in cylindrical bundles from a van, a statement from the agency said. It was the shape of the bundles that tipped agents off to the tunnel, the statement said.

"The marijuana bundles resembled previous seizures in which tunnels were used to smuggle narcotics from Mexico into the United States," the Immigration and Customs Enforcement statement said.

One opening of the 13-foot long tunnel had a 10-inch diameter hole in a street surface in Nogales. "The tunnel entrance in Mexico is directly against the International Border Fence and covered with a piece of plywood," the agency said. The tunnel will be filled with concrete.

The driver of the van fled, but a passenger was arrested and is facing federal drug and immigration charges, the agency said.

CNN's Kara Devlin and Mike M. Ahlers contributed to this report