New York's top court struck down a law that made cyberbullying a crime, in what had been viewed as a test case of recent state and local statutes that target online speech.

The New York Court of Appeals, in a 5-2 ruling, held on Tuesday that the 2010 Albany County law prohibited a vast swath of speech "far beyond the cyberbullying of children," in violation of the First Amendment.

The...