DUBAI (Reuters) - The U.S. and Chinese navies have carried out drills to combat pirates off the Horn of Africa, the U.S. Navy said on Tuesday, in a rare joint military exercise between the powerful nations.

Somali pirates have attacked hundreds of merchant ships in the Indian Ocean over the past few years, targeting everything from Middle East crude oil tankers to cargo ships loaded with Chinese goods bound for Europe and America.

U.S. guided-missile destroyer USS Winston S. Churchill paired up with Chinese navy frigate the Yi Yang on Monday for training in boarding, search and seizure.

It came during a busy week for international naval drills. The United States and its allies have launched a major exercise in the Gulf that they say shows a global will to keep oil shipping lanes open as Israel and Iran trade threats of war.

American and Chinese sailors worked side-by-side as a combined team practiced boarding the Churchill, which was simulating a pirated vessel.

"Piracy is a threat to the freedom of the seas, economic security, and the safety of mariners from all nations," Chris Stone, commanding officer of the Churchill, said. "Bilateral exercises such as this demonstrate the cooperative will of the international community."

(Reporting by Daniel Fineren; Editing by Pravin Char)