WASHINGTON — In a predawn raid on Tuesday, United States Special Operations commandos and Yemeni troops rescued eight hostages being held in a cave in a remote part of eastern Yemen by Al Qaeda’s affiliate there, officials from both countries said.

The freed captives were six Yemeni citizens, a Saudi and an Ethiopian, who were unharmed, Yemeni officials said in a statement. Earlier reports that an American hostage was freed were incorrect, according to Yemeni and American officials.

About two dozen United States commandos, joined by a small number of American-trained Yemeni counterterrorism troops flew secretly by helicopter to a location in Hadhramaut Province near the Saudi border, according to American and Yemeni officials. The commandos then hiked some distance in the dark to a mountainside cave, where they surprised the militants holding the captives.

An ensuing shootout left seven of the Qaeda militants dead, the officials said. The hostages were then evacuated in helicopters.