BEIJING -- China said Saturday its military seized a U.S. Navy unmanned underwater glider in the South China Sea to ensure the "safe navigation of passing ships," but would give back the drone after determining it was an American device.

The United States later confirmed it had "secured an understanding" for the return, seeming to settle one of the most serious incidents between the two militaries in years.

The Chinese navy on Thursday seized the drone, which the Pentagon said was being operated by civilian contractors to conduct oceanic research. The U.S. lodged a formal diplomatic complaint and demand the drone back.

Chinese Defence Ministry spokesman Yang Yujun issued a statement late Saturday saying that a Chinese navy lifeboat discovered an unknown device in the South China Sea on Thursday.

"In order to prevent this device from posing a danger to the safe navigation of passing ships and personnel, the Chinese lifeboat adopted a professional and responsible attitude in investigating and verifying the device," Yang said.

The statement said that after verifying that the device was an American unmanned submerged device, "China decided to transfer it to the U.S. through appropriate means."

The U.S. said that "through direct engagement with Chinese authorities, we have secured an understanding that the Chinese will return" the unmanned underwater vehicle, according to a statement from Peter Cook, spokesman for U.S. Defence Secretary Ash Carter.

The U.S. said China's "unlawful seizure" came in international waters.

Yet China pointedly accused the U.S. of long sending ships "in China's presence" to conduct "military surveying."

"China is resolutely opposed to this and requests the U.S. stop such activities," it said. "China will continue to maintain vigilance against the relevant U.S. activities and will take necessary measures to deal with them."

Earlier Saturday, China's foreign ministry said the country's military was in contact with its American counterparts on "appropriately handling" the incident, though it offered no details on what discussions were underway.

The drone was seized while collecting unclassified scientific data about 92 kilometres (57 miles) northwest of Subic Bay near the Philippines in the South China Sea, which China claims virtually in its entirety, Navy Capt. Jeff Davis, a Pentagon spokesman, said Friday.

"It is ours. It's clearly marked as ours. We would like it back, and we would like this not to happen again," Davis told reporters. He said the drone costs about $150,000 and is largely commercial, off-the-shelf technology.

The USNS Bowditch, which is not a combat ship, was stopped in international waters Thursday afternoon and recovering two of the gliders when the Chinese ship approached, Davis said. The two vessels were within about 450 metres (500 yards) of each other. He said that the USNS Bowditch carries some small arms, but that no shots were fired.

According to the Pentagon, as the Chinese ship left with the drone, which is about 3 metres (10 feet) long, its only radio response to the U.S. vessel was, "We are returning to normal operations."

President-elect Donald Trump blasted the seizure. Apparently misspelling "unprecedented," he tweeted Saturday: "China steals United States Navy research drone in international waters - rips it out of water and takes it to China in unpresidented act."

He later reissued the tweet, correcting the spelling to "unprecedented."

Bonnie Glaser, senior adviser for Asia at the Center for Strategic and International Studies, said the seizure of the glider occurred inside the exclusive economic zone of the Philippines, not China, and appeared to be a violation of international law.

China delineates its South China Sea claims with a roughly drawn sea border known as the "nine-dash line" that runs along the west coast of the Philippines. However, it hasn't explicitly said whether it considers those waters as sovereign territory, and says it doesn't disrupt the passage of other nations' shipping through the area. The U.S. doesn't take a position on sovereignty claims, but insists on freedom of navigation, including the right of its naval vessels to conduct training and other operations in the sea.

Davis said that the incident could be the first time in recent history that China has taken a U.S. naval vessel. Some observers have called it the most significant dispute between the sides' militaries since the April 2001 midair collision between a U.S. Navy surveillance aircraft and a Chinese fighter jet about 110 kilometres (70 miles) from China's Hainan island that led to the death of a Chinese pilot.

The drone seizure seemed likely to fray the already tense relations between U.S. and China. Beijing was angered by Trump's decision to talk by phone with Taiwanese President Tsai Ing-wen on Dec. 2, and by his later comments that he did not feel "bound by a one-China policy" regarding the status of Taiwan, unless the U.S. could gain trade or other benefits from China. China considers the self-governing island its own territory to be recovered by force if it deems necessary.

There also have been increased tensions over Beijing's ongoing military buildup in the South China Sea, mainly the development and militarization of man-made shoals and islands aimed at extending China's reach in the strategically vital area, through which about $5 trillion in global trade passes annually.