Sometimes the people at an inauguration jeer the president and his parade. Sometimes they’re happy. Unprecedented security protects the president and everyone who comes out to see him.

Pennsylvania Avenue was first sealed in 2001, but hundreds of protesters overcame short fences and overwhelmed understaffed barricades. Four years later, taller and stronger fences were specially ordered to stretch for miles. In 2009, those imposing steel rectangles helped control the record crowd celebrating President Barack Obama’s election. Both of his inaugurations saw citizens smiling for pictures with police instead of throwing food at them or burning flags.

“We had a big battle two inaugurations ago with a group that tried to breach the fence, but they never approached the parade route,” said Cathy Lanier, chief of the Metropolitan Police Department of the District of Columbia. “They never breached our fence.”

Law enforcement departments have managed violent protests and millions of people in the nation’s capital, and careful planning means they may be ready to handle both at the same inauguration. Coordination between hundreds of local and federal agencies is a “ballet” run “like clockwork,” according to the National Guard and the Metropolitan Police Department. About 800,000 people attended this year’s inauguration; 1.8 million in 2009. Riot gear and gas masks were standard issue when 300,000 people came to George W. Bush’s first inauguration and when 400,000 people arrived for his second. Lately the heavy gear stays in storage as more and more police commute from as far away as Seattle.

“We brought in 86 different law enforcement agencies — more than 2,000 cops,” Lanier said. The D.C. National Guard provided all military ground security before inviting 120 soldiers in 2005 to help. In 2009, more than 7,000 soldiers were asked to be there. Six thousand arrived in 2013.

The Secret Service is in charge of the National Special Security Event, partnered with the Metropolitan Police, U.S. Capitol Police, D.C. Fire and Emergency Management, D.C. Department of Transportation, U.S. Park Police, DHS, North American Aerospace Defense Command and the Joint Task Force National Capital Region.

Only 250,000 tickets let invited guests pass the tightest security and enter the Capitol’s west lawn. The only major glitch of 2009 led thousands of those ticketholders to be trapped for hours in the Third Street tunnel under the mall. Lanier said it was closed both years to everyone except emergency vehicles.

“The truck bringing the barricade to block that tunnel had a flat tire and he was delayed just long enough to let people start filling into that tunnel,” Lanier said. When the city’s filled to capacity, there’s nowhere for crowds to go, she added, but this year Twitter and text alerts kept subscribers away from congestion citywide. A new social media hub monitored the public’s tweets to head off problems before they grew. “We have 2,400 special events here a year,” she said. Experience helps.

“The biggest problem we had was the night before when marchers went to Chinatown and broke windows,” Lanier said. The same group of anti-war protesters briefly disrupted traffic by lying on the pavement. No arrests were made. Five permits for demonstrations near the parade route were granted.

U.S. Capitol Police arrested three people during the inauguration. Spokesman Shennell Antrobus said one had an open intoxicant and one was a fugitive from justice. “There was one demonstrator within the crowd who was subsequently arrested for breaking laws that pertain to the Capitol grounds,” Antrobus said. “But there were small demonstrations around the Capitol grounds that our officers successfully managed, which resulted in no arrests.” At an inaugural ball that evening, a Tennessee State trooper arrested a pickpocket.

All 3,900 city police officers worked 12-hour shifts. Each visiting department was assigned a liaison officer whose radio connected him or her to the communications hub. “If there was any need for radio communications, we would use him,” said Capt. Mike Murphy of the Philadelphia Police Department. “We were not that far spread out.” From his position, Murphy could see all 75 Philadelphia officers.

Delegation and coordination were key, said Secret Service spokesman Brian Leary. “There were several command posts in the area,” he said, led from “a Multi Agency Communications Center located outside Washington, D.C., where all agencies worked together. The MACC served as the central location where all participating agencies had a representative providing real-time updates for their agency’s command center.”

Designation as a National Security Special Event puts the Secret Service in charge. FEMA handles incident response and recovery operations, and the FBI leads incident investigations. Design and implementation of security and operational planning fall under the Secret Service.

Planning began a full year earlier. After the November election, Obama’s Presidential Inaugural Committee took charge of the day’s schedule. The committee held two formal balls instead of the 10 balls held four years ago, when 10,000 charter buses flocked to the Capitol. Fewer than 1,000 came this year.

All buses needed a trip permit from the District Department of Motor Vehicles and had to reserve parking before arriving. National Guard soldiers manned vehicle restricted zones from 7 a.m. the day before the inauguration until early the next day. An outer perimeter of the vehicle restricted zone was open to traffic, but drivers and passengers were advised to prepare to show “proof of residence, work identification or a reasonable verbal justification to enter the restricted area.” From 10 a.m. to 6 p.m. on the big day, the Federal Aviation Administration expanded the city’s National Defense Airspace. The usual military and civil VIP flights were all canceled. In addition, any private pilots flying over the city faced a license suspension, civil penalties, jail time and deadly force.

Buses stretched sideways across streets and large cement barriers slowed pedestrian movement across downtown. Restricted personal items along the parade and near the Capitol included any bags larger than 8 x 6 x 4 inches. No sticks or supports for signs were allowed, but the size of banners was barely restricted. “Signs and placards must be made only of cardboard, poster board or cloth and have dimensions no greater than three feet in width, 20 feet in length and one-quarter inch in thickness,” stated the advisory.

Dumpsters at the 11 parade entry points filled with water bottles and other banned items. Waiting for an hour or two in line ended under a white tent with Metropolitan Police officers asking for pockets to be emptied on long, slender tables before other officers waved metal-detecting wands over everyone.

Protesters learned in 2005 how sturdy and defensible the 10-foot tall steel fences are and none challenged the perimeter this year or in 2009. A 20-year-old activist named Marcus joined a group of 70 Earth First! and anarchist protesters, shadowed by a dozen police at McPherson Square before they left for a permitless march. “Washington, D.C., has turned into a micro police state,” he said. “Of course it limits our ability for public access, but we’re a loud enough group that we’re going to be heard anyway.”

Management of potential disruptions is more apparent than how the president is protected during and before the event. How long it takes to sweep the apartments and businesses along the parade route is not released, nor are tricks like securing manholes. “We cannot discuss the means, methods, specific resources or numbers we utilize to carry out our protective responsibilities,” the Secret Service spokesperson said.

But it is clear how quickly and efficiently the city transforms. Traffic zones appear and disappear by midnight. Pennsylvania Avenue is stripped of mailboxes, trash bins and even the streetlights that are anchored in the middle of the street. Most of it was back in place by the next morning when the road reopened. Downtown had no private vehicles one day and was as bustling as ever the next.

National Guard support units arrived Jan. 16 and left on Jan. 25. Like the visiting police officers, the guardsmen were deputized to assist local law enforcement. For the military, the 57th inauguration highlighted civilian control over the nation’s fighting forces. Soldiers outnumbered police, but the police and Secret Service were in charge.

Of the 6,000 soldiers supporting the inauguration, 2,000 marched in the parade. “They come from about 15 states and territories — Virginia, Maryland, Delaware, West Virginia, Pennsylvania, Iowa, even Puerto Rico, to name a few,” said Brig. Gen. Arthur W. Hinaman, commander of the Land Component Command for the District of Columbia National Guard.

It was the eighth inauguration for Maj. Gen. Errol Schwartz, commanding general of the Joint Force Headquarters for the District of Columbia National Guard. “Our soldiers and airmen have done this, on average, four times,” he said, adding that their regular mission of protecting the skies over the city remained in effect.

The “full spectrum operation” requires mechanics and logistical support to get other assets in place. “The military police or the security forces from the Air Force would have a good eye for those kinds of crowd management issues,” Schwartz said.

Every soldier is lodged within walking distance to his or her assignment, Schwartz said, and keeping track of everyone is his job. “We make sure that everyone who comes through the city is registered in our process, and a reverse process out of the city, so we can account for every individual and all equipment coming into the city,” he said.

The Joint Task Force selected the military units and also vetted 2,800 applications from citizen groups that hoped to march in the parade. They turned over 317 applications to the Presidential Inaugural Committee.

An enormous map of downtown D.C. spanned the floor of a practice arena, said Maj. Gen. Michael Linnington, commanding general of Joint Task Force National Capital Region, and it saw 20 rehearsals before the final performance.

“The military does rehearsals better than anybody,” he said. “It’s a very good tool for synchronizing events in time and space.”

How much the whole thing cost and who’s paying for it won’t be known for months. “For operational security reasons, we do not discuss the cost of security,” said Gwendolyn Crump, director of Metropolitan Police Department communications.

“We don’t give out the breakdown of the budget,” said Phillip Rumsey, spokesperson for the Joint Congressional Committee on Inaugural Ceremonies. The swearing-in ceremony cost $1.24 million in 2009, while security, transportation and emergency services cost the federal government $124 million. The bills are paid by private donations.

This story was originally published by Emergency Management magazine