President Barack Obama promised Monday that the United States would seek to halt the increasing threat of piracy off the Horn of Africa. Obama also praised the military's successful efforts to rescue merchant Capt. Richard Phillips, who had been held hostage there for several days by pirates. "His safety has been our principal concern," the president said in his first remarks in public on the five-day standoff that ended Sunday with Phillips' release. Obama spoke at an unrelated Transportation Department event involving the economic stimulus initiative. In a sharp warning to increasingly brazen pirates operating off the coast of lawless Somalia, Obama said: "I want to be very clear that we are resolved to halt the rise of piracy in that region and to achieve that goal, we're going to have to continue to work with our partners to prevent future attacks." "We have to continue to be prepared to confront them when they arise, and we have to ensure that those who commit acts of piracy are held accountable for their crimes," the president said. One day after elite Navy snipers killed the three pirates holding Phillips, Obama said he knew the cargo ship captain's safe return was a "welcome relief" to the man's family and crew. "I'm very proud of the efforts of the US military and many other departments and agencies that worked tirelessly to resolve this situation," Obama said. "I share our nation's admiration for Captain Phillips' courage and leadership, selfless concern for his crew." Earlier, Defense Secretary Robert Gates said piracy will be a top priority for the administration in the weeks ahead, even as he called the dramatic rescue a "textbook" success story. "I think we're going to end up spending a fair amount of time on this in the administration, seeing if there is a way to try and mitigate this problem of piracy," Gates told about 30 students and faculty members at the Marine Corps War College in Quantico, Virginia, according to a US military news service. He added: "All I can tell you is I am confident we will be spending a lot of time in the situation room over the next few weeks trying to figure out what in the world to do about this problem." Gates said the pirates were between 17 and 19 years old - raising the possibility that the one survivor now in US custody could be tried as a juvenile. That means he could potentially be charged with less harsh crimes than if he were an adult. "Untrained teenagers with heavy weapons," Gates said. "Everybody in the room knows the consequences of that." At the Pentagon, spokesman Bryan Whitman told reporters that other nations and the shipping industry would have to look at ways to make commercial traffic less vulnerable. That could include arming commercial ships, although that would prevent them from docking in ports of nations that prohibit civilian sailors from carrying weapons. Some in the shipping industry also worry that "if they were armed it could cause escalation" of attacks, Whitman said. But he said the slain pirates also could discourage future attacks on commercial ships sailing the Indian Ocean. "This could be a real discourager of people for which there have been relatively few penalties when they're engaged in this activity," Whitman said. "I think the actions that the US military took the other day could certainly have that effect." The pirates were killed after one pointed an AK-47 assault rifle at Phillips' back while he was tied up. Navy officials feared his life was in imminent danger. Phillips was not harmed in the rescue and is in good health. Efforts to crack down on cargo vessel seizures have done little to deter the onslaught of multimillion-dollar ship ransoms, as pirates have merely headed elsewhere to avoid the growing armada arrayed against them. More than 100 ships off the Horn of Africa have been assaulted over the past year by pirates based on the coast of Somalia. That prompted the Navy to focus on the Gulf of Aden - and the pirates to head southward into the Indian Ocean. Over the past week, pirates commandeered at least seven new ships, including the Maersk Alabama. The movement to the Indian Ocean is worrisome because the expanse is one of the world's most crucial shipping lanes, with oil vessels and other merchant ships carrying billions of dollars worth of cargo. Vice Adm. Bill Gortney, commander of the Navy's Central Command fleet, said officials have warned cargo ships to stay in deeper waters, away from the Somali coast, and to better protect themselves by hardening their ships against attacks. The Maersk Alabama was 230 nautical miles off the coast when pirates boarded before the crew fought back. Additional Navy ships have been sent to the region to patrol for pirates, Gortney said.