Image copyright AP Image caption Syed Rizwan Farook, right, and his wife Tashfeen Malik, killed 14 people at an office party on 2 December

The FBI has managed to unlock the iPhone of the San Bernardino gunman without Apple's help, ending a court case, the US justice department says.

Apple had been resisting a court order issued last month requiring the firm to write new software to allow officials to access Syed Rizwan Farook's phone.

But officials on Monday said that it had been accessed independently and asked for the order to be withdrawn.

Farook and his wife killed 14 in San Bernardino, California, in December.

They were later shot dead by police.

The FBI said it needed access to the phone's data to determine if the attackers worked with others, were targeting others and were supported by others.

US officials said Farook's wife, Tashfeen Malik, had pledged allegiance to the so-called Islamic State on social media on the day of the shooting.

Cracked iPhone: Should you be worried?

Israeli firm linked to hacked iPhone

UN human rights chief backs Apple

Apple boss hits back at FBI conduct

Last week, prosecutors said "an outside party" had demonstrated a possible way of unlocking the iPhone without the need to seek Apple's help.

A court hearing with Apple was postponed at the request of the justice department, while it investigated new ways of accessing the phone.

At the time, Apple said it did not know how to gain access, and said it hoped that the government would share with them any vulnerabilities of the iPhone that might come to light.

Media playback is unsupported on your device Media caption Apple's CEO Tim Cook: ''We have a responsibility to help you protect your data''

On Monday a statement by Eileen Decker, the top federal prosecutor in California, said investigators had received the help of "a third party", but did not specify who that was.

Investigators had "a solemn commitment to the victims of the San Bernardino shooting", she said.

"It remains a priority for the government to ensure that law enforcement can obtain crucial digital information to protect national security and public safety, either with co-operation from relevant parties, or through the court system when co-operation fails," the statement added.

Responding to the move, Apple said: "From the beginning, we objected to the FBI's demand that Apple build a backdoor into the iPhone because we believed it was wrong and would set a dangerous precedent. As a result of the government's dismissal, neither of these occurred. This case should never have been brought."

The company said it would "continue to increase the security of our products as the threats and attacks on our data become more frequent and more sophisticated".

Analysis: Dave Lee, BBC North America technology reporter

The court case that had the US technology industry united against the FBI has for the time being gone away.

Now this debate moves into more uncertain territory. The US government has knowledge of a security vulnerability that in theory weakens Apple devices around the world.

To protect its reputation, Apple will rush to find and fix that flaw. Assuming it can do that, this row is back to square one.

Therefore Apple has called for the matter to remain part of the "national conversation", while the US department of justice says it will still try to use the courts to compel Apple and other phone makers to help with future investigations.

Row just beginning

An Israeli newspaper last week reported that data forensics experts at cybersecurity firm Cellebrite, which has its headquarters in Israel, are involved in the case.

Cellebrite told the BBC that it works with the FBI but would not say more.

Its website, however, states that one of its tools can extract and decode data from the iPhone 5C, the model in question, among other locked handsets.

The court order had led to a vigorous debate over privacy, with Apple receiving support from other tech giants including Google, Microsoft, and Facebook.

FBI director James Comey said it was the "hardest question" he had tackled in his job.

However, he said, law enforcement saved lives, rescued children and prevented terror attacks using search warrants that gave it access to information on mobile phones.