WASHINGTON, July 12 (Reuters) - Mexico on Tuesday pledged to spend $1.5 billion to beef up its northern border as its leader met with U.S. President Joe Biden, who faces attacks from Republicans over his handling of immigration on the United States' southern flank.

Casting immigration as a "hemispheric challenge", Biden met Mexican President Andres Manuel Lopez Obrador and top Mexican officials in the White House to address U.S. concerns over migration and Mexico's desire for more worker visas.

In a joint statement, the two governments vowed to take "immediate and coordinated steps to manage the flows of migrants arriving into our countries" and to tackle soaring inflation by boosting bilateral trade and reducing trade costs.

The meeting came a month after Lopez Obrador skipped the U.S.-hosted Summit of the Americas in Los Angeles to protest Biden's decision to exclude the leftist governments of Cuba, Venezuela and Nicaragua.

"Despite the overhyped headlines we sometimes see, you and I have a strong, productive relationship," Biden said in remarks with his Mexican counterpart in the Oval Office.

Biden has struggled with more than 2.8 million arrests at the U.S.-Mexico border since he took office at the beginning of 2021, a record-setting level.

Biden touted a $3.4 billion U.S. investment to upgrade ports of entry along the borders with Mexico and Canada that was part of his bipartisan infrastructure plan passed last year, which he said would make the border safer and more efficient.

Mexico would spend $1.5 billion in border infrastructure between 2022 and 2024, the two governments said. Much of that money has been flagged in recent weeks.

The projects were for the U.S.-Mexico border, aimed at reinforcing infrastructure, extending and upgrading border crossings, as well as for the new Otay Mesa II port of entry between Tijuana and San Diego, a Mexican official said.

The two sides vowed to step up efforts to combat gangs, and Biden said the United States and Mexico would accelerate efforts to stop trafficking of the powerful synthetic drug fentanyl.

Lopez Obrador called on the United States to allow for more legal work visas, but Biden only went as far as highlighting existing programs used by Mexicans and Central Americans.

The Mexican president, who did most of the talking at a joint news event before the meeting, said the U.S.-Mexico-Canada trade agreement (USMCA) could be used to further integrate the three countries and that some tariffs and regulations could be suspended, although he did not specify which ones.

Turning to inflation - a political vulnerability for Biden - Lopez Obrador said some Americans were traveling to Mexico to buy gasoline amid high prices in the United States. He pledged to guarantee twice as much supply to meet that demand.

The two governments also said they would strengthen regional supply chains as well as move towards greener technologies. Mexican state oil firm Petroleos Mexicanos (Pemex) would work with the United States to craft a plan to eliminate flaring and venting in oil and gas operations, they said.