It was August 2004 in New York City and President George W. Bush was in town, attending the Republican National Convention at Madison Square Garden. Thousands of protesters were out in the streets in the sweltering summer heat, carrying placards emblazoned with slogans like “Push Bush Out The Door” and “The War on Terror is A Lie.” As the demonstrations rumbled on outside, the National Security Agency was getting to work on an unusual operation.

The agency, which mostly focuses on vacuuming up communications and monitoring events in foreign countries, had been drafted in to provide surveillance support to other federal agencies. A month earlier, in late July 2004, the NSA had served a similar role — using its vast electronic spying apparatus to bolster security at the Democratic National Convention in Boston. That’s according to a classified NSA document, published Monday by The Intercept, which offers a rare glimpse into the little-known circumstances surrounding the agency’s domestically focused missions.

NEW YORK - AUGUST 25:  Department of Homeland Security Secretary Tom Ridge speaks at a press conference August 25, 2004 in New York City. Ridge was in New York surveying security preparations for next week's Republican National Convention in Manhattan.  (Photo by Chris Hondros/Getty Images)

Department of Homeland Security Secretary Tom Ridge speaks at a press conference in New York City, on Aug. 25, 2004. Ridge was in New York surveying security preparations for the 2004 Republican National Convention in Manhattan.

Photo: Chris Hondros/Getty Images

The NSA became involved after then-Homeland Security Secretary Thomas Ridge and Attorney General John Ashcroft declared the conventions to be “National Special Security Events.” This designation came into existence following a secret directive issued in May 1998 by then-President Bill Clinton. The directive ensured that major gatherings of national or international significance would receive special federal resources to boost security, “with the goal of preventing terrorist attacks and criminal acts,” the classified NSA document explains. Between September 1998 and February 2008, there were 28 events approved for this extra level of protection, U.S. Department of Transportation records show. These included — aside from Republican and Democratic conventions — Super Bowls, presidential inaugurations, State of the Union addresses, and the Winter Olympics in Salt Lake City. It is not known whether NSA provided support to all of these events, but previous reporting — and a document published by The Intercept — have revealed that NSA was involved in carrying out surveillance at the Salt Lake City Olympics, where it worked with the FBI in a “fusion cell” known as the Olympics Intelligence Center.

The targets of NSA’s surveillance during the 2004 conventions — and whether they were foreigners, Americans, or both — are not disclosed in the agency’s documents, which were obtained by The Intercept from the whistleblower Edward Snowden. The documents do specify, however, that six employees from the agency’s Signals Intelligence Directorate were deployed to New York City and Boston for the events, and that their role was to provide “SIGINT [signals intelligence] support to the FBI, the Department of Homeland Security and other national agencies.” NSA staff were equipped with computers that linked them back to the agency’s headquarters in Fort Meade, Maryland. And if they gathered any intelligence they believed concerned a threat, they could get it declassified so that it could be shared with federal, state, and local officials on site who did not have security clearances.

NEW YORK - AUGUST 31:  Protesters are arrested at Union Square after attempting to march without a permit August 31,2004 in New York City. More than 260 people were arrested today, the second day of the Republican National Convention being held at Madison Square Garden.  (Photo by Paula Bronstein/Getty Images)

Protesters are arrested at Union Square after attempting to march without a permit on the second day of the Republican National Convention, in New York City, on Aug. 31, 2004.

Photo: Paula Bronstein/Getty Images

The Republican convention at Madison Square Garden took place over four days between August 30 and September 2. During some of the large-scale protests on the streets outside, the New York Police Department arrested more than 1,800 activists, bystanders, journalists, and lawyers. In 2012, after a lengthy court battle, federal Judge Richard J. Sullivan ruled that the arrests were illegal. Sullivan noted in his judgment that the NYPD had been responding “to a threat derived from intelligence sources — namely, that demonstrators aimed to ‘shut down the City of New York and the R.N.C.’ through ‘continuous unlawful behavior.’”

Patrick Toomey, a staff attorney with the ACLU’s National Security Project, said there needed to be transparency on whether NSA had eavesdropped on any communications about the demonstrations. “If NSA surveillance was used directly or indirectly to monitor protesters or domestic political activities, as opposed to detecting foreign threats, that would be a matter of serious concern,” Toomey told The Intercept. “The public should know more about the nature of any NSA surveillance, whether it swept up the private communications of Americans, and whether law enforcement relied on that information to monitor people exercising their First Amendment rights.”

The NSA declined to comment for this story. The Department of Homeland Security and New York Police Department had not responded to requests for comment at time of publication. A spokeswoman for the FBI said she could not comment because she had no knowledge of the 2004 operation.

Top photo: A group carrying what was described as 1,000 coffins representing the U.S. dead in Iraq marches past Madison Square Garden during the anti-Bush march organized by United for Peace and Justice in New York, on Aug. 29, 2004, on the eve of the Republican National Convention.