Police have gone out of state to hone their skills at detecting hidden bombs. The National Guard expects to send armed military police officers for the first time in more than a decade. And there will be significantly more bomb-sniffing dogs, undercover officers, and surveillance cameras, especially near the finish line where the throng is thickest.

With two months to go before the Boston Marathon, state and municipal officials are working at a feverish pace to lock in a comprehensive safety plan to secure the 26.2-mile route that begins in Hopkinton and crosses six other towns before ending at Copley Square.

They have grappled with how to prevent another attack, mobilize an emergency response should tragedy strike, and provide security that will be tight but not intimidating to spectators used to intimate interactions with runners. The race is famous for the closeness between the marathoners and the half million people who typically line the route, where children reach out to high-five runners and college students are known to ply runners with hugs and kisses.

At least twice as many spectators are expected to cheer on the runners this year — many of them, police believe, motivated by a sense of defiance against last year’s terrorist attacks that killed three people and injured at least 260.

“Everybody wants to come out and be part of this,” said Boston Police Commissioner William Evans. “I think we’re going to see the biggest numbers we’ve had, bigger than the 100th anniversary.”

Authorities said they have yet to determine whether they will ban coolers, backpacks, or other bulky bags along the course, and have not yet settled on a final plan for crowd management near the Boylston Street finish. But they but expect to announce restrictions in the coming weeks.

Some changes are already planned, however. Officials will erect more barriers along the route to separate the runners from the crowds. The FBI said it plans for the first time to deploy a SWAT team and a unit that specializes in recovering evidence from deadly crime scenes and sites of mass disaster, in addition to other specialized teams, like bomb technicians, that usually help with Marathon security.

Runners will only be able to bringfanny packs or energy belts, Evans said. In the past, runners took personal belongings with them to Hopkinton, which were then bused to the finish line. This year, the runners will have to leave any bags at the Boston Common, where they will be under constant surveillance by police.

“There are a lot of different changes to sort of tighten up some loose ends where we might think there may be a security risk,” Evans said.

State Police plan on using the same portable surveillance cameras along the route that they used during the July 4 fireworks on the Esplanade, where tight security was cited as one of the reasons for lighter crowds.

In Hopkinton, officials told the Boston Athletic Association, which organizes the Marathon, that their event permit hinged on having a security plan, a request the town rarely makes.

“The rubber stamping that has gone on in the past is not the case this year,” said Brian Herr, a Hopkinton selectman and a marathoner who will run this year’s race on April 21, his 25th consecutive run.

This year’s field of runners has been expanded from 27,000 to 36,000, making it second only to the centennial race in 1996, when there were 38,708 registered runners.

Typically an estimated 50,000 to 60,000 people — including runners and spectators — cram Hopkinton’s streets along the starting point, according to Herr.

Spectators may not be able to get as close to the starting line as they used to and vendors, who hawk yogurt, granola bars, and other snacks, may get more scrutiny before they can set up in Hopkinton’s town common, said State Police Colonel Timothy Alben.

Still, no one wants the carnival-like atmosphere that takes over Hopkinton on Marathon Day to be replaced with one that feels more like martial law.

“We cannot have a thousand armed military personnel come into Hopkinton and pull out AK-47s,” Herr said. “We can’t create a military zone.”

Since August, more than 100 police and fire chiefs, municipal leaders, emergency medical personnel, and state and federal officials have held dozens of meetings to organize security plans around the Boston Marathon, which winds through Ashland, Framingham, Natick, Wellesley, Newton, and Brookline.

The planning is in stark contrast to past years, when meetings began about January and involved a review of the prior year’s plans but few changes.

“There’s much greater intensity,” said Kurt Schwartz, the head of the Massachusetts Emergency Management Agency, which has coordinated the meetings.

One of the goals is to make sure all the cities and towns along the Marathon route could respond to an emergency as quickly as law enforcement and medical officials did last year when two pressure-cooker bombs hidden in backpacks exploded on Boylston Street.

“The loss of life could have been substantially higher if there hadn’t been such good planning in place,” Schwartz said. “How do we ensure that we can do that across 26 miles and not just at the finish line?”

The meetings, held at least once a week at the MEMA bunker in Framingham, centered on topics such as new training for police; better ways to communicate with hospitals and trauma centers in case of mass casualties; and options for emergency personnel if cell towers go down and people cannot communicate by phone.

Another group will take their recommendations and create a cohesive plan, Schwartz said, which will be in addition to any security measures cities and towns take on their own.

In Brookline, police are planning to set up barriers along the route where there used to be none and restrict parking on some side streets to ensure ambulances can easily reach hospitals in Brighton and the Longwood area.

In Wellesley, Deputy Police Chief Jack Pilecki said all officers have been told “if you’re not running, you’re working.”

In Boston, people with backpacks along Boylston Street and in Kenmore Square are likely to be checked thoroughly by police — if they are allowed in those areas at all, Evans said.

Last year the National Guard sent about 400 soldiers and airmen, including 100 military police officers to help with crowd control. This year, it will again send 400 personnel, but 300 of them will be armed military police. Governor Deval Patrick gave the order that the military police officers carry handguns this year, said National Guard spokesman Lieutenant Colonel James Sahady.

“It is a deterrent,” Sahady said. “But say we have a couple of military police soldiers in an area and something happens . . . They have to be in a position to protect themselves and civilians.”

Unregistered runners — known as “bandits” — who jump in the crowd of marathoners, will face more scrutiny from police and Marathon organizers.

“Usually, they’re pretty light on them,” Evans said, but this year, officials will make periodic checks along the route to stop and turn away anyone who does not have a number.

Thomas S. Grilk executive director of the Boston Athletic Association, said organizers are urging bandits to stay away because they unnerve registered runners and create safety woes. “They just don’t quite know the impact they have,” he said.

State Police, for the first time at the Marathon, will be giving the public a text-a-tip line to report anything suspicious. In Hopkinton, Police Chief Charles Wallace said they will ask residents of the town to call the police and fire departments if they notice unusual activity, such as someone trespassing in a neighbor’s yard, in the days leading to the Marathon.

“We are never going to reduce the risk to zero in any event, especially ones that attract hundreds of thousands of people, but we have to do the best we can to reduce that risk, to get it as low as possible,” Alben said.

And police know they just can’t stop some traditions. Evans said he expects runners will still wear superhero costumes. In Wellesley, the extra officers won’t try to block Wellesley College students who gather to plant kisses on runners.

“I don’t think it would be possible to keep the girls from that interaction,” said Pilecki.