Get the latest federal technology news delivered to your inbox.

Justification questions RIM’s long term viability.

This story has been updated to add details.

The Immigration and Customs Enforcement agency plans to end its eight-year relationship with the BlackBerry in favor of iPhones, according to solicitation documents posted Friday. The move could prove a major blow to ailing BlackBerry maker Research In Motion.

ICE plans to purchase iPhones for more than 17,000 employees, according to the notice, which states that RIM’s technology “can no longer meet the mobile technology needs of the agency.”

The defection by a law enforcement agency is a particularly harsh blow for RIM, which has led the mobile market in security even as it has trailed Apple’s iPhone and Google’s Android operating system in functionality.

Apple ultimately bested RIM based on market viability, according to a limited source justification, which describes RIM as “a distant fourth” in the mobile devices market and says “firms with poor performing products or unsustainable business models will be removed from the marketplace.”

On a score sheet, the agency gave RIM two out of five points for commercial viability compared with five out of five for Apple and Google’s Android.

The agency gave both Apple and RIM top security scores in the justification. ICE praised the companies for controlling both the hardware and operating systems in their products. Google’s Android, which received a low security score, provides only the operating system and allows other companies to run it on their mobile devices.

“What is a strength for Google is a risk for ICE,” the justification states.

“Analysis conducted by ICE has concluded that for the near term, Apple iPhone services offer the agency the best solution for its mobile technology,” the justification says. “Apple’s strict control of the hardware platform and operating system, independent of telecommunication vendor, provides ICE with the greatest degree of control and management to ensure the most reliable delivery of services to ICE’s mission users.”

RIM had not responded to a request for comment on the ICE purchase by 5 p.m. Friday.