Lego has found its next precious.

Warner Bros. Consumer Products has awarded the toymaker the rights to create action figures and playsets based on “The Lord of the Rings” trilogy and the two upcoming films based on “The Hobbit,” the first of which bows at the end of 2012.

The multiyear deal grants Lego access to the library of characters, settings and stories of “The Lord of the Rings,” “The Hobbit: An Unexpected Journey” and “The Hobbit: There and Back Again,” all helmed by Peter Jackson.

The first toys Lego plans to produce will hit store shelves in June, tied to “Lord of the Rings,” with new construction sets planned for the weeks leading up to the Dec. 14 bow of “An Unexpected Journey.”

“Only Lego, with their expertise in the construction category, is capable of doing justice to the incredibly imaginative environments depicted in the world of ‘The Lord of the Rings’ and the two films based on ‘The Hobbit,'” said Karen McTier, executive VP, domestic licensing and worldwide marketing, Warner Bros. Consumer Products. “These films give life to amazing worlds and characters and we are thrilled to bring fans these products that deliver an imaginative play experience befitting of these beloved properties.”

Warner Bros. has a long history with Lego.

Lego has produced toys around the studio’s “Harry Potter” franchise, the Batman and “Speed Racer” pics and now the entire DC Comics library. Lego also has tied toys to Disney’s “Pirates of the Caribbean,” “Toy Story,” “Cars” and “Prince of Persia” pics, and has long had the “Star Wars” and “Star Wars: The Clone Wars” license.

Warner Bros.’ Lego-made DC toys are also expected to hit store shelves next year, the same time Lego will also release its Marvel line, tied to Sony’s “The Amazing Spider-Man” and Disney’s “The Avengers.”

“Our collaboration with Warner Bros. Consumer Products has delivered numerous worldwide successes in the construction toy aisle, introducing us to loyal audiences who love great stories, strong characters and the toys that they inspire,” said Jill Wilfert, VP, licensing and entertainment for the Lego Group. “It’s particularly exciting to now be able to create sets based on the fantasy worlds and characters from ‘The Lord of the Rings’ trilogy and ‘The Hobbit,’ not only because we know they will foster collectability and creative play, but also because these are two properties that our fans have been asking us to create for years.”

Going after film franchises has paid off for Lego, with “Harry Potter” and “Star Wars” helping the toymaker top $1 billion in sales in the U.S. for the first time in 2010, a figure it’s confident to repeat again this year. Altogether, sales are up 106% for the fourth-largest toymaker since 2006, the company has said.

This year, shipments of Legos to stores between August and October are up more than 65%, according to Panjiva, a New York-based data firm.