Apple chief executive Tim Cook defended on Wednesday night his company's controversial refusal to help the FBI access the passcode-locked iPhone belonging to one of the shooters in last December's San Bernardino terrorist attack.

Cook said that helping the FBI to bypass the iPhone's security "could expose people to incredible vulnerabilities."

"This would be bad for America," Cook said during an interview on ABC's World News Tonight With David Muir.  "It would also set a precedent that I believe many people in America would be offended by."

This was Cook's first public interview since a federal magistrate judge in Riverside, Calif., last week ordered Apple to develop a way to access the iPhone belonging to Syed Rizwan Farook, one of the two shooters who killed 14 people and injured 22 in a Dec. 2 shooting rampage. Cook had previously written a public letter objecting to the court order. That touched off a heated national debate over questions about technology and surveillance. Cook had also sent an email to Apple employees making his case.

[Apple vows to resist FBI demand to crack iPhone linked to San Bernardino attacks]

Cook said Apple tried to help the FBI with other technological solutions, "significant advice" on how the iPhone might be cracked. But Apple does not want to go as far as the FBI says it now needs -- writing software to get around the phone's security measures. Cook called it "the software equivalent of cancer."

"What is at stake here is can the government compel Apple to write software that we believe would make hundreds of millions of customers vulnerable around the world, including the U.S., and also trample civil liberties that are the basic foundation of what this country are made of ," Cook said.

Cook said this case was about the future, rather than this one particular iPhone.

FBI Director James B. Comey, in a letter published Sunday, wrote that this case highlights the tension between privacy and safety.

"That tension should not be resolved by corporations that sell stuff for a living," Comey wrote.

Cook, in his interview, insisted that obeying by this one court order means opening hundreds of other Apple devices that law enforcement wants access to, as well.

"It is a slippery slope. I don't fear one -- it is one," Cook said.

Cook said that these issues should be settled by a debate and legislation in Congress.

[Showdown over iPhone reignites the debate around privacy]

Muir asked if Cook ever has any doubts that opening this iPhone might help prevent a terrorist attack.

"David, some things are hard and some things are right. And some things are both," Cook said. "And this one of those things."