Alcohol, Tobacco and Firearms (ATF) officers confer near the finish line of the Boston Marathon on April 16. (DON EMMERT/AFP/GETTY IMAGES)

It’s the agency that Congress and the National Rifle Association love to hate.

But the Bureau of Alcohol, Tobacco, Firearms and Explosives, which hasn’t had a director in seven years, has been at the heart of two searing events over the past two weeks — the investigations of the Boston Marathon bombing and the explosion that leveled a fertilizer plant and part of a town in central Texas.

In the hours after the coordinated blasts near the finish line of the April 15 marathon, ATF agents were on their hands and knees on Boylston Street. They were scouring the debris for remnants of the bombs, the first excruciating steps in reconstructing the devices.

Two days later, a massive explosion occurred at a fertilizer plant in West, Tex. Since then, dozens of ATF investigators, along with local and state agents, have been sifting through a deep crater that was once a factory and the vast expanse of charred ground that spreads out from the center of the blast.

In the hunt for the suspected bombers in Boston, attention has focused on the FBI and the Boston Police Department, but investigators said that ATF, with its expertise in explosives, has played a critical role behind the scenes.

“The ATF brings an institutional knowledge of previous bomb incidents around the country and around the world,” said Chuck Wexler, executive director of the Police Executive Research Forum. “In Boston, they tried to reconstruct the device, looking at the component parts and feeding that information into their bomb data center to see what may be similar to other devices used around the world.”

One of ATF’s most experienced explosives technicians was coincidentally a few blocks from the blasts because he was working out of the Boston office, said Assistant ATF Director Richard W. Marianos. The agent rushed to the scene and began to help secure evidence, figure out what explosive was used and determine how the bombs were detonated.

The agency soon had more than 100 people in Boston, along with bomb-sniffing dogs, called “explosives-detection canines,” and their handlers. It is the same role that ATF played after the Oklahoma City bombing in 1995 and in New York after the attacks of Sept. 11, 2001.

ATF also will try to trace a gun allegedly used by Tamerlan Tsarnaev, the suspected marathon bomber who was killed in a shootout with ­police. His younger brother, Dzhokhar, is recovering from multiple gunshot wounds at a Boston hospital and has been charged in the attack.

“In an investigation like this, the ATF is the Marines to the FBI’s Army,” said Jim Cavanaugh, a former senior ATF agent. “The Army is a million soldiers in charge of the battle and the Marines are 300,000, but the Marines are critical to the fight because of their special skills and the way they operate.”

Despite its expertise, ATF has long gotten short shrift in Washington. In January, President Obama nominated B. Todd Jones, the acting, part-time director, to be the permanent head of ATF. But the Senate has not scheduled a confirmation hearing. Since 2006, when the ATF director was first required to gain Senate approval, the gun lobby has blocked the nominees, law enforcement officials said.

Despite its $1.1 billion budget, ATF has fewer agents than it did nearly four decades ago, about 2,360. For the past several years, the agency has been buffeted by criticism on Capitol Hill over a botched operation to track guns from U.S. dealers to Mexican drug traffickers.

For all the political turmoil, ATF has remained central to major investigations of bombings and explosions in the United States.

About 50 ATF personnel were dispatched to the Texas fertilizer plant, where they are central in determining what caused a fire before the explosion and what chemicals were stored at the facility. The explosion killed 14 people, injured 200 and caused widespread damage.

“A fire scene is complicated in itself, but you compound that with an explosion and it really complicates the issue,” ATF Special Agent in Charge Robert Champion told reporters at the scene.

A day after the Texas explosion, more than 100 ATF agents and intelligence officers were sent to Warren, Ohio, for the kind of operation the agency works every week. After an investigation of a drug trafficking group, 55 people were charged in federal court and state charges were brought against an additional 42. At the same time, 22 people on the agency’s national response team were working on a large serial-arson case in California.

“We don’t get a lot of accolades, but we go out there with the resources we have and we try to accomplish the mission,” Marianos said.