WASHINGTON — It started as a medical mystery. It then was determined to have been the result of a mysterious attack. And on Friday, the illness that has affected 21 diplomats at the American Embassy in Havana, with symptoms including hearing loss and cognitive difficulties, threatened the future of Cuban-American relations.

With no guarantee that the Cuban government could protect American diplomats, the State Department announced that it was withdrawing all nonessential personnel from the embassy.

In a statement, Secretary of State Rex W. Tillerson repeated the American assertion that the embassy personnel were deliberately targeted. But he did not blame Cuba, and officials held out the possibility that a third party might have been responsible. “Cuba has told us it will continue to investigate these attacks, and we will continue to cooperate with them in this effort,” Mr. Tillerson said.

But the Trump administration, which has already expelled two Cuban diplomats over the illnesses, is considering further retaliatory steps, according to Congressional staff briefed by administration officials. And the State Department issued an advisory that Americans should not travel to Cuba. Because some of the attacks occurred in hotels where State Department employees were temporarily staying, officials said they worried that tourists and others could be affected.