The small gang of Somali pirates fired on an approaching ship, hoping their midnight attack would bring them millions in ransom. The ragtag bandits, though, had taken on far more than they could handle: a U.S. warship.

The USS Nicholas, a guided missile frigate, was tracking the pirates when they opened fire early Thursday in Indian Ocean waters, the U.S. military said. The Nicholas, which saw combat in the first Gulf War, returned fire and disabled the skiff.

Navy personnel later boarded and detained three suspects. The Americans found two more bandits on a nearby mothership and later sank the skiff.

Get Breaking News Delivered to Your Inbox

It was not the first attack against a Navy ship, but it underscored the fact that most pirates aren't terribly sophisticated, said Roger Middleton, a piracy expert at the British think-tank Chatham House.

"If you think of the kind of young men who are doing this, they go out into the middle of the ocean in a tiny boat. They might not always make rational decisions, and they often attack things that are bigger than they should (attack)," said Middleton.

"It's also quite possible that they don't have a full understanding of the targets they are attacking. Perhaps they just see a big ship they think is a worth a lot of money," he said.

International naval forces have stepped up their enforcement of the waters off East Africa in an effort to thwart a growing pirate trade. Thursday's attack took place between the coast of Kenya and the island nation of Seychelles, said Navy Lt. Patrick Foughty, a spokesman.

Last May, pirates chased a U.S. Navy warship and fired small arms at it. The ship, which had recently served as a prison for captured pirates, increased speed and evaded the attack. French and Dutch naval ships also have been attacked by pirates.

Thursday's attack came just shy of a year since pirates attacked the U.S.-flagged Maersk Alabama and took American Richard Phillips hostage. Phillips was rescued five days later when Navy SEAL snipers shot three pirates in a lifeboat.

The U.S. Africa Command said the five pirates seized Thursday would remain in U.S. custody on board the frigate for now. The Nicholas is home-ported in Norfolk, Va.

Foughty, the Navy spokesman, said it wasn't yet clear what would be done with the pirate suspects. Doug Burnett, a maritime expert in the global law firm Squire, Sanders and Dempsey, said the five should be charged with piracy and tried in the United States.

"After all, attacking a Navy warship is a pretty obvious pirate cause of action. But the U.S. has not been consistent in trying pirates," he said. "The one for the Maersk Alabama is on trial in New York. But others have been let off or sent to Kenya for trial."

Experts say piracy will continue to be a problem until an effective government is established on Somalia's lawless shores. The country has not had a functioning government for 19 years.

The USS Nicholas served in the first Gulf War, attacking Iraqi positions off the coast of Kuwait and capturing the first Iraqi prisoners of war. The Nicholas also rescued a downed F-16 pilot from the waters off the Kuwait coast.

Meanwhile, the Taiwan government said it fears a Taiwanese fishing boat may have been hijacked by pirates off the Somali coast. Officials lost contact with the 79-ton Jih-chun Tsai 68 fishing trawler on Wednesday.