On Independence Day 1914, New York experienced a powerful dynamite explosion that killed four people and injured dozens.

As police investigated the scene — a tenement house on Lexington Avenue in East Harlem — they discovered the bodies of three notorious anarchists. Further searches unearthed bomb fragments, radical literature and evidence of a plot to assassinate John D. Rockefeller. The device had detonated prematurely, instantly killing its creators.

Last month, the United States was horrified and captivated by another terrorist attack. A longer perspective on terrorism and counterterrorism in U.S. history reveals clear patterns that — especially at times, like these, of high emotion — are worth recalling.

Violence against civilians (or assassination attempts on leading figures) has inevitably led to increased repression, security and surveillance. The reaction is understandable, but the laws and institutions that arose from previous episodes were far more effective at stifling free speech, chilling dissent and breeding distrust than they were at preventing future attacks. No regulation has consistently stopped determined terrorists.

The first age of terror lasted from about 1886 to 1920 and was defined by a campaign against radical anarchists who believed that violent means could bring about an economic and social revolution. Today’s “If You See Something, Say Something” society has its origins in this largely forgotten past.

The initial wave of terrorism was largely carried out by European immigrants: Italians, Germans and Russians. In 1886, an unknown anarchist killed seven policemen with a homemade grenade in Chicago’s Haymarket Square. In the ensuing hysteria, four radicals were hanged (a fifth committed suicide in prison), despite a lack of evidence connecting them directly to the crime. Yet the reprisals did nothing to slow the campaign of violence.

In subsequent years, a series of attacks, near-attacks and threatened conspiracies were used to justify an unprecedented set of governmental security measures, as fear of anarchists often blurred with prejudice against immigrants and black Americans.

The very aspects of U.S. society that made it a beacon to the peoples of the world came to be seen as grave disadvantages. When an Italian immigrant living in New Jersey traveled home to assassinate the Italian king, U.S. law-enforcement officers bemoaned the lack of a centralized national police force, similar to the Italian Carabinieri, the French Surete or Scotland Yard’s Special Branch. It’s worth noting that terrorist violence remained endemic in Europe despite the labyrinthine spy networks.

Fears about domestic terrorism reached new heights in 1901 when President William McKinley was assassinated by an anarchist in Buffalo, N. Y . In response, Congress enacted a sweeping immigration law known as the Anarchist Exclusion Act of 1903. The legislation was the first to cite ideological justifications as a valid reason to bar foreigners from entering the U.S. It was largely ineffectual because most anarchists in the U.S. hadn’t arrived as radicals, but had become politicized by conditions in American factories.

Less than one month after the July 4, 1914, explosion on Lexington Avenue, the New York Police Department announced the creation of a new secret service, the Anarchist and Bomb Squad, its first permanent counterterrorism task force. The unit’s officers employed the most modern techniques, as well as elaborate disguises and subterfuges. Even so, the most devastating bombing campaign in the city’s history occurred in the squad’s first years. Explosives detonated in city churches and courthouses across the boroughs. No one was ever arrested.

When the U.S. entered World War I, in April 1917, counterterrorism and anti-radicalism efforts spread far beyond New York. The Military Intelligence Division, the Secret Service, the Justice Department’s Bureau of Investigation (later to become the FBI), and vigilante volunteers harassed anarchists, socialists, Germans or anyone else who failed to support the war.

These steps impinged on free speech, devastated labor unions and destroyed the Socialist Party, but they didn’t curb terrorism. The most brazen campaign of bombings occurred in 1919 and 1920. Mail bombs sent to dozens of prominent politicians and capitalists were intercepted by alert postal workers. But in June 1919, powerful bombs detonated in seven cities, including Washington, where the home of U.S. Attorney General A. Mitchell Palmer was damaged.

In response, hundreds of the most notorious anarchists and communists were deported to the newly founded Soviet Union. In late 1919 and early 1920, the attorney general and his young protege, J. Edgar Hoover, authorized a series of mass arrests — known as the Palmer Raids — which stand as one of the most repressive government actions in U.S. history.

It was also ineffective. On Sept. 16, 1920, dynamite detonated near the Wall Street headquarters of J.P. Morgan. It was lunch hour and the street was packed. Almost 40 people were killed and 400 were injured.

It was the deadliest terrorist strike attack on U.S. soil until the attacks of Sept. 11, 2001. Despite a huge manhunt, the identities of the perpetrators were never discovered.

In the years after World War I, there was a growing acknowledgement that the government had gone too far. Organizations such as the American Civil Liberties Union were founded to curb infringements on free speech and the right to dissent. Their work created a new understanding of the importance of constitutional rights and the idea that more freedom, not less, is the best guarantee of security.

Thai Jones is an assistant professor of history at Bard College’s Master of Arts in Teaching Program.