The U.S. military launched Tomahawk cruise missiles against radar sites in Yemen early Thursday, a senior defense official said.

The strikes followed two incidents this week in which missiles were fired at a U.S. Navy ship from a rebel-controlled area of the country.

The missiles were launched from the destroyer USS Nitze at around 4 a.m. Thursday local time (9 p.m. Wednesday ET), and initial assessments were that all three coastal sites in rebel Houthi-controlled areas were destroyed, the official said.

Pentagon press secretary Peter Cook said in a statement that President Barack Obama authorized the strikes on the recommendation of Secretary of Defense Ash Carter and Chairman of the Joint Chiefs General Joseph Dunford.

"These limited self-defense strikes were conducted to protect our personnel, our ships, and our freedom of navigation in this important maritime passageway," Cook said. "The United States will respond to any further threat to our ships and commercial traffic, as appropriate, and will continue to maintain our freedom of navigation in the Red Sea, the Bab el-Mandeb, and elsewhere around the world."

A map showing the location of the Bab el-Mandeb Strait.Google Maps

The Pentagon on Tuesday vowed to retaliate after a pair of missiles were fired at the Navy destroyer USS Mason Sunday as the ship was in international waters near the Bab el-Mandeb Strait.

On Wednesday, a coastal defense cruise missile was fired from a Houthi-controlled area south of Al Hudaydah at around 6 p.m. local time (11 a.m. ET). None of the missiles struck the ship, and there were no injuries, U.S. officials said.

Yemen is embroiled in a civil war between Shiite Houthi rebels fighting the government of President Abed Rabbo Mansour Hadi that broke out in March 2015.

On Saturday, 140 people were killed when a Saudi-led coalition airstrike hit a funeral hall packed with mourners in the capital of Sanaa, The Associated Press reported citing a U.N. official.

"Anybody who puts U.S. Navy ships at risk does so at their own peril," Capt. Jeff Davis, a U.S. Defense Department spokesman, said Tuesday.

In Wednesday's missile launch against the USS Mason, that ship and the USS San Antonio were in international waters north of the Strait of Bab el-Mandeb when the Mason got an indication they were being targeted, a U.S. military official told NBC News.

A Houthi radar station in Yemen locked on — or "painted" — the Mason and then the ship determined that missiles were inbound and a defensive system fired, the official said. SM-2 and Sea Sparrow defensive missiles were launched and engaged "well away from the ship," the official said.

The official said the U.S. was confident Houthis were aware they were targeting the U.S. ship because spotters were seen nearby, the official said.