A security guard protecting a federal building in lower Manhattan was fatally shot Friday evening by a gunman, who then took his own life, authorities said.

The shooting occurred shortly after 5 p.m. in the lobby of the building at 201 Varick St. near West Houston Street, police said.

NYPD Chief of Department James P. O'Neill said the gunman approached a metal detector and fired on the guard "at close range" with a handgun before rushing through the device toward an elevator.

photosRecent NYC mug shotsSee alsoMajor NYC crime

There, the shooter encountered another employee of the building and shot himself in the head, O'Neill said. He was pronounced dead at the scene.

The contract security guard, Idrissa Camara, 53, of Manhattan, was unable to unholster his firearm in time to defend himself, O'Neill said.

Officials said there was no indication that terrorism was a factor. Federal Homeland Security Secretary Jeh Johnson arrived on the scene and toured the building.

advertisement | advertise on newsday

"I wanted to be here, because the shooting victim . . . is part of our protective services," Johnson said. "It's obviously a tragedy when anyone is killed like this in the line of duty."

The shooter was identified by police as Kevin Downing, 68, of Fort Lee, New Jersey.

Members of the NYPD respond to a shooting at a federal building at 201 Varick St. in lower Manhattan on Friday, Aug. 21, 2015. Photo Credit: CS Muncy

Investigators trying to determine a motive planned to search Downing's home. "He had an intended target beyond the security officer," said O'Neill, declining to elaborate.

Get the Newsday Now newsletter!

The best of Newsday every day in your inbox.

John Miller, the NYPD's deputy commissioner for counterterrorism, said Downing was a former employee of the federal Bureau of Labor Statistics and apparently a military veteran.

Camara worked for FJC Security Services, founded in 1988 by a former NYPD officer with offices in Manhattan, Melville, Floral Park, Queens, and several other cities. "Camara . . . was an extraordinary senior guard who was well-trained, cared deeply about his job and knew that building better than anyone else," FJC said in a statement.

The victim was rushed to Lenox Health Greenwich Village, where he died, the NYPD said. A cousin, Muhammad Ouattara, said the family is distraught. He said Camara was an NYPD traffic cop for seven years.

"We are shocked and horrified at this terrible news and send our deepest condolences to Officer Camara's family," said Hector Figueroa, president of 32BJ Service Employees International Union. "We are heartbroken that one of our own has fallen."The building where the shooting occurred houses a number of federal agencies and an immigration court.

An image posted on Twitter shows police and other emergency personnel outside a federal building at 201 Varick St. in Manhattan after a gunman killed a security guard and then himself on Friday, Aug. 21, 2015. Photo Credit: Twitter / Shane Kennedy

The scene outside was chaotic by early evening, with emergency and police vehicles whizzing through the streets during peak rush hour. Spectators lined the sidewalks behind police tape as helicopters buzzed overhead.

advertisement | advertise on newsday

"The police came and told us to close our shop because there was an active shooter in there," Florencio Xelo, 48, a cook at the nearby Fresh Tortillas Tex-Mexican Food restaurant, said in Spanish. With Maria Alvarez