WASHINGTON — In a major First Amendment ruling, the Supreme Court on Tuesday struck down a federal law that made it a crime to create or sell dogfight videos and other depictions of animal cruelty.

Chief Justice John G. Roberts Jr., writing for the majority in the 8-to-1 decision, said that the law had created “a criminal prohibition of alarming breadth” and that the government’s aggressive defense of the law was “startling and dangerous.”

The decision left open the possibility that Congress could enact a narrower law that would pass constitutional muster. But the existing law, Chief Justice Roberts wrote, covered too much speech protected by the First Amendment.

It has been more than a quarter-century since the Supreme Court placed a category of speech outside the protection of the First Amendment. Tuesday’s resounding and lopsided rejection of a request that it do so, along with its decision in Citizens United in January — concluding that corporations may spend freely in candidate elections — suggest that the Roberts Court is prepared to adopt a robustly libertarian view of the constitutional protection of free speech.