Research In Motion says the U.S. Immigration and Customs Enforcement will test its new BlackBerry 10 devices early next year, becoming one of the first government agencies to try the new operating system.

U.S. Immigration will test the handsets along with RIM’s new enterprise software designed for large corporate and business customers, the Waterloo, Ontario-based company said in a statement.

[RIM also operates a research and deveopment office in the Research Triangle Park, N.C. area.]

RIM (Nasdaq: RIMM) is counting on the new BlackBerry 10 operating system to win back market share lost in recent years to Apple Inc.’s iOS and Google Inc.’s Android operating systems. While consulting firm Booz Allen Hamilton and the National Transportation Safety Board have dropped BlackBerry phones, U.S. Immigration plans to use devices from both RIM and Apple.

The pilot project is a “prudent” technology management practice and doesn’t conflict with a separate plan to buy iPhones made by Cupertino, California-based Apple, said Barbara Gonzalez, press secretary for the agency.

“We’re not backing away from iOS, nor RIM,” she said, in a telephone interview. “We’ve had a long and good relationship with RIM.”

RIM is picking up the tab for the pilot project, Nick Manning, a company spokesman, said.

The agency said in an Oct. 17 solicitation document that it plans to spend $2.1 million on iPhones for 17,676 employees.

U.S. Immigration, part of the Department of Homeland Security, is developing mobile applications for law enforcement and is looking into how BlackBerrys may be able to provide those services in the future, Gonzalez said.

RIM gained 4.1 percent to $13.86 at the close in New York. The stock has more than doubled since a rally that began Sept. 24, just before the company’s last earnings report. RIM is scheduled to report earnings Dec. 20.