MEXICO CITY – Acknowledging uncertainty ahead, President Barack Obama said Thursday the U.S. will cooperate with Mexico in fighting drug-trafficking and organized crime in any way Mexico’s government deems appropriate. Mexican President Enrique Pena Nieto emphasized that the security relationship must be expanded to focus on trade and commerce.

Appearing alongside Pena Nieto at a news conference, Obama recommitted the U.S. to fighting the demand for illegal drugs in his country and the flow of illegal guns across the border to Mexico, even as the southern neighbor rethinks how much access it gives to American security agencies.

“I agreed to continue our close cooperation on security, even as the nature of that cooperation will evolve,” Obama said. “It is obviously up to the Mexican people to determine their security structures and how it engages with other nations – including the United States.”

Obama’s remarks come as Pena Nieto, in a shift from his predecessor, has moved to end the widespread access that U.S. security agencies have had in Mexico to help fight drug-trafficking and organized crime. The White House has been cautious in its public response to the changes, with the president and his advisers saying they need to hear directly from the Mexican leader before making a judgment.

Pena Nieto, speaking at the news conference in Spanish, downplayed the notion that the new arrangement would mean less close cooperation with the United States. “There is no clash between these two goals,” he said.

He said Obama told him the U.S. will “cooperate on the basis of mutual respect” to promote an efficient security strategy.

The two leaders met Thursday on the first day of Obama’s three-day trip to Mexico and Costa Rica, his first visit to Latin America since winning re-election. Obama was met at the steps of his plane by an honor guard and a bugler before heading to the National Palace for his meetings with the Mexican leader.

Seeking to put a new spin on a long-standing partnership, Obama is promoting jobs and trade – not drug wars or border security – as the driving force behind the U.S.-Mexico relationship. But security concerns nonetheless shadowed the visit.

“With the new Mexican administration coming into office, it certainly stands to reason that President Pena Nieto would want to take a look at the nature of our cooperation,” said Ben Rhodes, Obama’s deputy national security adviser. “So we’re currently working with the Mexicans to evaluate the means by which we cooperate, the means by which we provide assistance.”

The White House, hoping to move the discussion surrounding the president’s trip beyond security, has emphasized in recent days a desire to boost economic ties to Mexico.

Already the economic relationship between the two countries is robust, with Mexico accounting for $500 billion in U.S. trade in 2011 and ranking as the second-largest export market for U.S. goods. A stronger Mexican economy would result in even more trade and job growth on both sides of the border, Obama aides say.

Among the cadre of advisers traveling with the president is Michael Froman, a longtime White House international economic adviser who was nominated by Obama just hours before the trip to serve as the next U.S. Trade Representative.

A host of other pressing issues are vying for Obama’s attention as he launches his quick trip to Mexico and then to Costa Rica. Among those issues are possible chemical weapons use in Syria, the arrest of three more people in connection with the Boston Marathon bombings, and the delicate immigration negotiations underway on Capitol Hill.

Obama will be looking for a nod of support for the immigration effort from Pena Nieto. The Mexican leader is expected to back the effort, although it’s unlikely he will take a public position on specific components of any pending legislation in order to avoid the impression that Mexico is meddling in U.S. domestic politics.

Still, Pena Nieto’s support – particularly for stricter border security efforts – could help Obama sell the measure to wary Republicans, many of whom have long opposed giving legal status to people in the country illegally before securing the border. A bipartisan Senate bill Obama is backing would make a pathway to citizenship for people in the U.S. illegally contingent on a secure border.

“They are critical to our ability to secure the border,” Rhodes, the Obama adviser, said of Mexico. “All the immigration plans that have been contemplated put a focus on securing the border as an essential priority and starting point for immigration reform.”

On Friday, Obama will speak to an audience of Mexican students before heading to Costa Rica for talks with Central American leaders. His meetings there are expected to focus on bolstering regional economic cooperation, as well as security issues.