SAN SALVADOR, El Salvador — Under the shadow of the Libyan war, President Obama sped to the finish of his Latin American journey Tuesday, promising a better U.S. fight against the violent drug trade that plagues Central America and undermines the security of an entire region.

In El Salvador, Obama again found his time diverted and his agenda eclipsed by the U.S.-led military campaign against Libyan leader Moammar Gadhafi. He was scuttling a trip to Mayan ruins today in favor of a national security meeting on Libya, then will be returning to Washington earlier than scheduled.

Obama promised a new partnership across Central America to increase trade and economic growth, target drug trafficking and create opportunities so that people can find work in their home countries and “don’t feel like they have to head north to provide for their families.”

He also said anew that he would push for a comprehensive reform of immigration laws in the United States, including a “pathway to get right by the law” for those who live in the country illegally. But that volatile issue is stalled in Congress and shows no signs of political life.

Obama’s trip was designed to show an engagement in the Americas, create markets for U.S. goods and build up relations with democratic nations whose political support the U.S. needs in coping with security threats, climate woes and energy prices.

The security partnership that Obama announced is intended to address not just Central America, but the U.S. and the broader hemisphere given the spillover effects of drugs, gangs and guns.