On July 24, 1915, the World War was raging in Europe and the belligerents were vying for the sympathy of the neutral United States. In Lower Manhattan, on a Sixth Avenue elevated train, Secret Service agents were tailing George Sylvester Viereck, a German propagandist and a mysterious companion of his—who was, unbeknown to the agents, Heinrich F. Albert, an attaché in the German Embassy. When Viereck got off at 23rd Street, one agent followed him; Albert continued on to 50th Street, where he suddenly looked up from his newspaper, noticed he had reached his stop, and hurried off the car, leaving behind a brown briefcase that the second agent promptly seized. A chase ensued, but the purloined bag ultimately made it to Treasury Secretary William McAdoo, who shared it with President Woodrow Wilson.

The documents that Wilson and McAdoo beheld detailed a sweeping secret campaign, linked to high-ranking German officials, of espionage, sabotage, and propaganda. There were plans to take over American newspapers, bankroll films, send hired lecturers on the Chautauqua circuit, and create pseudo-indigenous movements to agitate on behalf of pro-German policies. More disturbing were schemes to provoke strikes in armaments factories; to corner the supply of liquid chlorine, an ingredient in poison gas, in order to keep it from Allied hands; even to acquire the Wright Brothers’ Aeroplane Company and use its patents on Germany’s behalf. American officials also learned of sabotage plans hatched by a different German spy, Franz Rintelen von Kleist, who was plotting to destroy American munitions plants and blow up the Welland Canal, a Canadian waterway of vital importance to the United States. It was no wonder that Wilson wrote to his adviser Edward House that summer that the country was “honeycombed with German intrigue and infested with German spies.”

Although these plots are omitted from most discussions of the 1917 Espionage Act—the law now being invoked by those who would prosecute WikiLeaks mastermind Julian Assange—they go a long way toward explaining (but not excusing) that unfortunate piece of wartime legislation. When Wilson made the case for entering the world war, he warned that “if there should be disloyalty, it will be dealt with with a firm hand of stern repression.” Contrary to some interpretations, the president wasn’t perversely touting his intention to trample civil liberties; he was grimly cautioning would-be saboteurs, like those who had blown up the supply depot at Black Tom, New Jersey, the year before, not to undermine the combat effort.

The Espionage Act had a legitimate purpose: to try to stop the real threat of subversion, sabotage, and malicious interference with the war effort, including the controversial reinstatement of the draft. It’s context that’s worth recalling as Democrats and Republicans alike clamor to use the law against Assange

On April 6, 1917, Congress declared war on Germany and for the next nine weeks it engaged in robust, contentious debate about the proper scope of an espionage bill. Some elements were struck from the first drafts. Originally, the White House wanted to censor the press, but Congress—reflecting fierce resistance in the newspapers—killed the provision. A provision to let the postmaster general regulate the mails remained, but was narrowed to restrict suppressible materials to those urging treason or lawbreaking that would hinder the war effort. A ban on efforts to “cause disaffection” in the military was replaced with a more closely tailored prohibition on efforts to cause insubordination, mutiny, or disloyalty—that last word used, as it was in Wilson’s speech, to mean disloyal action, not private sentiment. Overall, the act wasn’t meant, as it has often been represented, to stifle antiwar dissent, but to address particular wartime problems that officials had good reason to worry about: draft avoidance, sabotage, espionage.

Nonetheless, the Espionage Act was deeply problematic. Above all, its wording, even in its softer version, left far too much room for aggressive prosecutors and overzealous patriots to interpret it as they wished. (Things got worse the next year when Congress passed more draconian amendments that came to be called the Sedition Act; that law outlawed statements during war that were “disloyal, profane, scurrilous, or abusive … about the form of government of the United States.” Unlike the Espionage Act proper, though, the Sedition Act was repealed when World War I ended.)

The resulting crackdown on antiwar groups under the Espionage Act—and the shame it brought to Wilson and the nation—is widely known. Postmaster General Albert Burleson, a reactionary and intolerant Texan considered by Edward House to be “the most belligerent member of the cabinet,” denied use of the mails to publications like the left-wing Masses and scared many others into silence. Around the country, meanwhile, the U.S. attorneys in Thomas Gregory’s Justice Department prosecuted socialists, pacifists, and German-Americans on flimsy grounds. Many people were arrested for crimes of mere speech. Filmmaker Robert Goldstein was prosecuted for making a movie about the American Revolution that depicted the British—now a U.S. ally—in an unfavorable light. The socialist leader Eugene Debs was thrown in jail for a speech that defended freedom of speech. Of 1,500 arrests under the law, only 10 involved actual sabotage. To the dismay of progressives, moreover, not even the Supreme Court stopped the prosecutions. In March 1919, the liberal icon Oliver Wendell Holmes, coining his famous “clear and present danger” standard, led the court in upholding three dubious Espionage Act verdicts, including the conviction of Debs.

It has been common to view the Espionage Act as the product of a paroxysm of wartime hysteria. There’s obviously some truth to that view. In 1917 and 1918, war fever drove many politicians, in all three branches of government, to lose sight of basic rights—just as during other wars a sense of urgency led Abraham Lincoln to wrongfully suspend the habeas corpus writ and subject civilians to military trials, and Franklin Roosevelt to approve the internment of Japanese-Americans. But just as the presence of real communist spies during the early Cold War years helps to explain (but, again, not excuse) the witch hunts that followed, so the legitimate fears of German saboteurs constitute an important piece of the context in which the Espionage Act became law.

The real problem occurred not in its drafting but in its application. All laws are enforced selectively. Discretion always shapes which possible violations of a law are prosecuted and which are deemed unwise to pursue. In deciding whether to indict Assange, President Obama—who has already endorsed the worst of George W. Bush’s civil-liberties violations, the indefinite jailing of suspects without trial—might do well to consider how his decision will look in the light of history. Wilson’s greatness is sullied today because of the license he granted to Gregory and Burleson to abuse the act; conversely, Richard Nixon’s reputation as our worst president is only enhanced by his attempt to use the law to retaliate against Pentagon Papers leaker Daniel Ellsberg.

Assange’s case is different, of course, from Ellsberg’s, but it’s still far from clear that his posting and sharing of classified government documents—as embarrassing and frustrating to diplomats as their publication may be—amounts to the kind of sabotage or espionage that the law was intended to punish. A former professor who taught his students ably about the Constitution, Woodrow Wilson would fare better in the history books today had he instructed his Cabinet officials more emphatically that laws on the books are only as wise as the people who enforce them.

Like Slate on Facebook. Follow us on Twitter.