Updated

Facebook and Twitter have come out in support of Apple's decision to fight a court ruling ordering it to unlock an iPhone used by the San Bernardino terrorists.

FBI director James Comey has said his agents were locked out of one of the killer's phones since the mass shootings in December last year.

The Justice Department filed court papers asking for Apple to load software on to the phone to bypass a self-destruct feature that erases all data after 10 failed attempts to guess the passcode.

A judge ordered Apple to develop a workaround for its encryption software, but company boss Tim Cook said the move would "threaten the security of our customers".

Apple is preparing to fight the court order, which it said would set a dangerous precedent that could ultimately undermine the security of its products.

Facebook has now released a statement declaring support for Apple's stance while insisting it supported the police and security services in their fight against terrorism.

"We condemn terrorism and have total solidarity with victims of terror," it said.

"Those who seek to praise, promote, or plan terrorist acts have no place on our services. We also appreciate the difficult and essential work of law enforcement to keep people safe.

"When we receive lawful requests from these authorities we comply. However, we will continue to fight aggressively against requirements for companies to weaken the security of their systems.

"These demands would create a chilling precedent and obstruct companies' efforts to secure their products."

Twitter boss Jack Dorsey tweeted the social network supported the "leadership" shown by Cook.

Apple insists it is doing all it can to help without compromising the security of the iPhone.

"The FBI asked us for help in the days following the attack, and we have worked hard to support the government's efforts to solve this horrible crime," Tim Cook said in a statement, adding: "We have no sympathy for terrorists."

Click for more from Sky News.