China will return a U.S. drone that its navy seized from international waters, military officials from both nations confirmed.

The Pentagon reached a deal Saturday with the Chinese to turn over a Navy research drone a Chinese crew removed Thursday from the South China Sea.

“Through direct engagement with Chinese authorities, we have secured an understanding that the Chinese will return the [underwater unmanned vehicle] to the United States,” Pentagon press secretary Peter Cook said.

Chinese military leaders “expressed regret” over the incident but slammed American leaders for overreacting to the drone’s capture.

“China and the United States have been communicating about this process. It is inappropriate and unhelpful for a resolution that the U.S. has unilaterally hyped up the issue,” said Chinese Defense Ministry spokesman Sr. Col. Yang Yujun early Saturday.

U.S. military officials did not disclose when or how the drone would be returned but said they objected to China’s “unlawful seizure” of their equipment.

Negotiations over the transfer of the drone came as President-elect Trump accused China of stealing the research device.

“China steals United States Navy research drone in international waters – rips it out of water and takes it to China in unprecedented act,” he tweeted Saturday morning, only hours before the deal was announced.

Connecticut Democratic Sen. Chris Murphy tweeted that Trump’s “escalation of a diplomatic crisis with China” was “madness.”

But Republican Arizona Sen. John McCain called the incident a “flagrant violation of the freedom of the seas” and said Friday the country “must not stand for such outrageous conduct.”

A U.S. Navy oceanographic research vessel had deployed the drone about 100 miles from the U.S. Navy base at Subic Bay in the Philippines.

Pentagon officials said the drone was merely measuring ocean conditions in the region. But Chinese officials accused the U.S. of conducting “surveillance and military surveys” with the equipment.

Tensions between the global powers were already rising when the president-elect received a post-election congratulatory phone call from Taiwan’s president last month. Some criticized Trump for breaking diplomatic protocol surrounding the longstanding U.S. “one China” policy. Others applauded Trump’s boldness.

Some experts speculated China targeted the drone in response to Trump’s increasingly confrontational rhetoric.

“Knowing Chinese military officials for many years and how orders are communicated from the highest power centers in Beijing down to commanders on the ground or water, this was very likely a highly planned and escalatory move to show China will not take [these] matters lightly,” Harry Kazianis, director of defense studies at the Center for the National Interests, told The Hill.