Good news for anyone who wants to borrow a library book, or buy or sell secondhand goods on eBay or Craigslist: the Supreme Court ruled today that these activities are still legal. Specifically, in Kirtsaeng v. John Wiley and Sons, the court ruled 6-3 that “first sale” doctrine is not limited to items made or purchased within U.S. borders.

Kirtsaeng v. Wiley went before the Supreme Court last October. The plaintiff, Supap Kirtsaeng, was a Thai native attending college in the U.S. John Wiley and Sons is a publisher best known for its “For Dummies” books, but they also publish college textbooks, including some that were required for Kirtsaeng’s classes.

New college textbooks in Thailand sell for much less than the same books in the U.S. So Kirtsaeng had his relatives buy inexpensive books in Thailand and mail them to him in America, where he sold them to bargain-hunting college students for a profit. Wiley and Sons sued to prevent this on copyright grounds, and Kirtsaeng argued that his actions were legal under the doctrine of first sale.

First sale doctrine says that a copyright holder only gets paid the first time an item is sold. When you buy a brand-new book, the copyright holder gets a share of the proceeds. However, once you’ve bought the book, it is yours, and you’re free to sell it, lend it out or give it away.

Wiley, the publisher and copyright holder of the textbooks, sued Kirtsaeng, claiming that first sale rights only apply to goods sold in the U.S. A lower court sided with the copyright holder, basically ruling that U.S. residents did not have the right to resell any foreign-made or -sold items they owned without permission from the items’ copyright holder.

But the Supreme Court decided otherwise. In a 74-page ruling and opinion, written by Justice Breyer and released on March 19, the court rejected Wiley’s “geographical interpretation” of the first sale doctrine, basically ruling that “first sale” applies to any copyrighted item bought legally (as opposed to pirated), regardless of where that first legal sale took place.

Justices Ruth Bader Ginsburg, Antonin Scalia and Anthony Kennedy disagreed. The three justices (along with the Obama administration) sided with Wiley and other copyright holders against the likes of Kirtsaeng and his customers, arguing in their dissenting opinion that first sale rights should not apply to foreign-made or foreign-bought items, since copyright holders deserve legal protection “against the unauthorized importation of low-priced, foreign-made copies of their copyrighted works.” In other words, John Wiley’s high-priced American books should not have to compete against John Wiley’s low-priced Thai books in the American marketplace.

Stephen Smith, the president and CEO of John Wiley and Sons, said in a press release that “We are disappointed that the U.S. Supreme Court has decided in favor of Supap Kirtsaeng [….] It is a loss for the U.S. economy, and students and authors in the U.S. and around the world.”

But American libraries and library fans considered the court’s ruling a victory. Kevin Smith of Duke University noted that “It appears that the Court took very seriously that ‘parade of horribles’ that were suggested if they upheld the Second Circuit—libraries would be unable to lend some materials without a license from publishers, students could be prevented from buying or selling second-hand textbooks, etc. According to the Court, these were too distressing, and too likely to occur. [….] It seems that libraries have really ducked a bullet here.”

But librarians—and secondhand book sellers like Kirtsaeng—shouldn’t relax too much. Six out of nine Supreme Court justices interpreted the first-sale copyright law in their favor—but Congress can rewrite that first sale law anytime it wants to. Justice Elena Kagan, who voted with the majority in favor of Kirtsaeng, said as much in a separately published opinion.

So it’s still legal for you to sell your British-edition Harry Potter (or Thai edition college textbook) … but the law might change, if Congress decides international publishing conglomerates and other poor little rich copyright holders need legal protection from secondhand book buyers, bargain-hunting college students and other buyers of discount stuff.

Photo via TexasGOPVote/Flickr