WASHINGTON — The U.S. recently conducted a cyberattack against an Iranian military ship that had been collecting intelligence on cargo vessels in the Red Sea and the Gulf of Aden, according to three U.S. officials.

The cyberattack, which occurred more than a week ago, was part of the Biden administration’s response to the drone attack by Iranian-backed militias in Iraq that killed three U.S. service members in Jordan and wounded dozens of others late last month, the officials said.

The operation was intended to inhibit the Iranian ship’s ability to share intelligence with Houthi rebels in Yemen who have been firing missiles and drones at cargo ships in the Red Sea, the officials said. U.S. officials say Iran uses the ship to provide targeting information to the Houthis so their attacks on the ships can be more effective.

One of the U.S. officials with knowledge of the cyberattack said the operation was conducted on an Iranian ship named the MV Behshad. The other officials declined to disclose the ship’s name. 

A spokesperson for the National Security Council declined to comment and referred questions to the Defense Department, which also declined to comment.

U.S. officials typically do not disclose covert operations, including cyberattacks, and have not publicly released information about the one involving the suspected Iranian spy ship.

In an interview with NBC News’ Lester Holt last week, Iran’s U.N. ambassador, Amir Saeid Iravani, said the Behshad is in the Red Sea “to combat the piracy activities” and is not providing intelligence to Houthi forces.

Since January, the Behshad has been operating near the port of Djibouti, close to a Chinese military base on shore, according to ship tracking data. Military analysts say it is possible Iran has chosen to move the ship near the Chinese base to discourage U.S. naval forces from trying to physically attack or board the suspected spy vessel. 

Roughly 12% of global shipping passes through the Red Sea every day. In the wake of repeated Houthi attacks since November, shipping giants like Maersk have announced pauses in their operations in the Red Sea and the Gulf of Aden, which will add time and money to delivery of goods.

Houthi rebels, who have long been supported and armed by Iran, have vowed to continue the attacks until Israel halts its military operations in the Gaza Strip.

When President Joe Biden ordered a response to the attack that killed the U.S. soldiers in Jordan, administration officials said it would be carried out on multiple fronts and potentially over several weeks. The response began with airstrikes in Iraq and Syria on Feb. 2. NBC News previously reported that it would include both military strikes and cyber operations. 

Iran issued a video warning Feb. 4 not to target the Behshad. Asked about the ship last week, the Pentagon press secretary, Maj. Gen. Patrick Ryder, said he was not aware of the U.S.’ targeting the Behshad but added, “We are very well aware of the ship.” 

The deaths of the three American service members in the Jan. 28 attack on the logistics support base at Tower 22 of the Jordanian Defense Network followed more than 160 attacks on U.S. forces in the region by Iranian-backed militants, according to U.S. officials.

The Pentagon said last week that the U.S. retaliatory strikes had killed or wounded more than 40 Iranian-backed militants in Iraq and Syria. The U.S. also announced it had killed a commander of the Iran-backed Kataib Hezbollah militia — the group that administration officials say was behind the attack in Jordan — in a drone strike in Baghdad.

Despite the U.S. military response to the killing of the three American soldiers, U.S. officials have told NBC News that Iran continues to provide arms and intelligence to its proxies in the region.