China’s Defense Ministry says it will return the U.S. Navy underwater drone it captured operating in international waters in the South China Sea, after it seized the device to ensure the “safe navigation of passing ships.”

Yang Yujun, a ministry spokesman, issued a statement late Saturday saying a Chinese navy lifeboat discovered the unknown device in the South China Sea on Thursday, according to the Associated Press.

China’s Defense Ministry said that, after verifying that the device was an American unmanned device, “China decided to transfer it to the U.S. through appropriate means.”

Pentagon spokesman Peter Cook confirmed that "through direct engagement with Chinese authorities, we have secured an understanding that the Chinese will return the UUV to the United States," he said in a statement using an acronym for the unmanned underwater vehicle.

China's defense ministry said it originally seized the drone “to prevent this device from posing a danger to the safe navigation of passing ships and personnel,” the statement said, according to AP. It added: "the Chinese lifeboat adopted a professional and responsible attitude in investigating and verifying the device."

President-elect Donald Trump weighed in on the incident earlier Saturday, accusing China of stealing the drone.

"China steals United States Navy research drone in international waters - rips it out of water and takes it to China in unprecedented act," Trump said in an early morning tweet.

Trump originally misspelled “unprecedented” as "unpresidented" but later deleted the tweet and reposted.

The incident comes amid renewed tensions between China and the U.S. after the election of Trump, who’s vowed to get tough on Chinese trade policies and stirred anger in Beijing after a 10-minute phone call with Taiwan President Tsi Ing-wen. It was the first by a U.S. president or president-elect since President Jimmy Carter acknowledged in 1979 China's position that Taiwan is part of “One China.”

In its statement, China also accused the U.S. of deploying “ships in China’s presence to conduct reconnaissance and military surveying. China is resolutely opposed to this and requests the U.S. stop such activities.”

The drone was launched by the USNS Bowditch, a civilian crewed oceanographic ship that is operated by the Military Sealift Command, off the coast of the Philippines. These types of drones, called gliders, typically collect unclassified data, such as water temperatures and salinity levels.

According to Cook, the drone is not armed and is used for gathering weather and temperature data. The incident occurred Thursday.

The Bowditch was about to recover the glider when a Chinese Dalang III class Chinese warship approached within 500 yards of the Bowditch, launched a small vessel and snatched the drone out of the water, the Pentagon said.

The boat brought the device back to the Chinese warship, which then headed away.

The Bowditch contacted the Chinese vessel by radio and demanded the return of the glider. The Chinese ship acknowledged the radio transmission but ignored the request to return it, the Pentagon said.

The U.S. government had issued a démarche, or diplomatic protest, over the incident, demanding its return.