In an eerie foreboding of the deadly Boston Marathon blasts, the state’s top emergency agency ran a training drill in March 2012 that specifically activated a plan for an attack that included bombs at the race finish line as well as one under the VIP grandstand on Boylston Street, officials said.

“It was always something we had to be concerned about ­— that someone would want to target it to make a political statement,” Peter Judge, director of the Massachusetts Emergency Management Agency, told the Herald. “This isn’t just our little race. There are 200 countries represented here, and it’s being watched across the world.”

Judge said the agency, which coordinates disaster response plans, runs training exercises every March that focus on responding to a variety of crises, including terrorism, dangerous weather, accidents and mass casualties at the marathon.

Last year, one of the exercises included training for “bombs at the finish line,” as well as a bomb planted under the grandstand on Boylston Street, he said.

The exercise prepped local, state and federal agencies how to coordinate and respond to such an attack.

“It was not based on a threat,” Judge said. “We look at a whole variety of events every year.”

But the bombing training proved crucial to the response that followed the April 15 terrorist attacks. Runners were stopped in their tracks and directed to “safe havens” along the race route, while MBTA buses picked up stranded competitors. Medics in the race tents sprinted with wheelchairs and stretchers to the scene, while emergency responders and hospitals were ready.

“That wasn’t thinking on the fly,” Judge said. “That was stuff we had prepared for.”