(Reuters) - A federal appeals court panel on Thursday ordered that eight of 17 books that had been removed from a Texas library's shelves over conservatives' complaints that they were inappropriate must be returned.

The New Orleans-based 5th U.S. Circuit Court of Appeals panel said in a 2-1 ruling that partially upheld a lower court's injunction that the library in the small town of Llano had infringed on defendants' First Amendment rights to information by removing some of the books.

Nine of the books, however, can remain off library shelves pending the final outcome of the appeal, because one judge found they were not removed because of any ideas or viewpoints they contained, but because they were focused on "juvenile, flatulent humor."

"Government actors may not remove books from a public library with the intent to deprive patrons of access to ideas with which they may disagree," Judge Jacques Wiener wrote in the majority opinion.

Among the books ordered returned to the library shelves are "Caste: The Origins of our Discontent," by Pulitzer Prize-winning author Isabel Wilkerson, and "They Called Themselves the K.K.K.: The Birth of an American Terrorist Group," by Susan Campbell Bartoletti. A book about a transgender teenager was also among the eight books ordered to remain on library shelves.

Judge Leslie Southwick concurred with Wiener that officials cannot remove books from library shelves simply because they dislike the ideas contained within them.

But Southwick wrote that he differed with Wiener in the law's application. Southwick ruled that nine of the books could remain off library shelves pending final outcome of the lawsuit over their removal, because he did not think they were removed because of any ideas within them.

"Viewpoints and ideas are few in numbers in a book titled 'Gary the Goose and His Gas on the Loose' - only juvenile, flatulent humor," Southwick wrote in the concurring opinion, referring to one of the books that can remain off library shelves.

The third judge on the panel, Stuart Duncan, said in a dissent that none of the books should be ordered to be returned to the library shelves.

Llano, with a population of about 22,000 and located about 60 miles northwest of Austin, has been a flashpoint in a battle over books in libraries across the U.S. in recent years.

Republican lawmakers in Texas and several other conservative states have pushed for the removal of books from library shelves, volumes they say are inappropriate for children and that mostly involve LGBTQ and race issues.

In Llano, seven library patrons filed a federal lawsuit in 2022 over the removal of 17 books. The lawsuit had been scheduled to go before a trial jury last October, but was put on hold pending the 5th Circuit's decision; it will apparently now proceed.

In March 2023, U.S. District Judge Robert Pitman issued a preliminary injunction ordering that all the books be returned to shelves, which they were.

Then in April 2023, the Llano County commissioners briefly considered simply closing all library branches in the county amid the fight, though ultimately they kept the libraries open.

Wiener, in the 5th Circuit's majority opinion, wrote that the plaintiffs in the lawsuit "have demonstrated a likelihood of success on the merits of their First Amendment claim" and for that reason he agreed with the lower court's injunction to return all books.

Lawyers for the defendants in the lawsuit - which includes the county commissioners, library officials and the county judge, the chief elected official at the county level - did not immediately reply to requests for comment. The defense can ask that the entire 5th Circuit hear their case, and ask that the U.S. Supreme Court hear it.

(Reporting by Brad Brooks in Longmont, Colorado; Editing by Leslie Adler)

By Brad Brooks