WASHINGTON — The two U.S. warships in the Middle East weren’t aiming to break a record.

But when the coronavirus made ship stops in foreign countries too risky, the USS Dwight D. Eisenhower and the USS San Jacinto were ordered to keep moving and avoid all port visits.

On Thursday, as they steamed through the North Arabian Sea, they notched their 161st consecutive day at sea, breaking the previous Navy record of 160 days. And they’re on pace to crush it, since they won’t hit land again until they get home to Virginia later this year.

The milestone, Navy Capt. Kyle Higgins said, “is not one that I think we really wanted but one that the circumstances of the world thrust upon us. And we embraced it with style.”

When the ships left home in January, COVID-19 was just starting to emerge.

By the time they crossed the Atlantic and moved into the Mediterranean Sea, the virus was escalating.

In March, Vice Adm. Jim Malloy, the Navy’s 5th Fleet commander, ordered a stop to all port visits to reduce the chance of spreading the virus through the fleet.

Other ships were battling outbreaks, including the USS Theodore Roosevelt, which got sidelined in Guam.

With that, Higgins, the Eisenhower commander, and Capt. Edward Crossman, the San Jacinto commander, knew their sailors wouldn’t set foot on land for some time. Both were interviewed a few days before the ships broke the record.

For more than five months, the Eisenhower, an aircraft carrier, and the San Jacinto, the guided-missile cruiser that accompanies it, have been at sea, with no onboard visitors and strict controls over how aircraft deliver their supplies.

The isolation has been challenging.

Port calls not only give sailors time for rest and relaxation, they also allow experts to come aboard to do difficult repairs.