U.S. Customs and Border Protection personnel walk along a section of fence at the U.S.-Mexico border. Getty Images

President Donald Trump's plans to build a wall along the United States' southern border is inflaming relations between the United States and Mexico. It's a contentious issue, considering the border wall would cost billions of dollars. On Thursday, Trump threatened to cancel a meeting with Mexican President Enrique Peña Nieto, after Peña Nieto reiterated that Mexico would not pay for it. On Thursday, Senate leader Mitch McConnell, R-Ky, said Congress will follow through on Trump's border wall order, and McConnell estimated it will cost $15 billion at most — he cited a range of $12 billion to $15 billion.

The U.S. border with Mexico is roughly 2,000 miles long and underlines four states, from California to Texas, more than half of it along the Colorado River and Rio Grande. It is a massive stretch of land — the Berlin Wall spanned just 96 miles comparatively, and it cost about $25 million to build in 1961, or around $200 million with inflation. Building a wall to keep out illegal immigrants is not a novel plan. About 670 miles of fencing on the U.S.–Mexico border was completed in accordance with the Bush administration's Secure Fence Act of 2006. That alone cost about $2.4 billion, for roughly one-third of the entire border and, according to migration experts, some of the easier and less costly areas to fence. The Secure Fence Act called for 700 miles of fencing, with a double layer throughout, but much of the barrier isn't reinforced this way. Even before the fence reached its first stage of completion, some argued it was not being constructed properly. "It's a lot more expensive than we expected when we started, and it was much more difficult," said Ronald Vitiello, deputy chief of border patrol for the U.S. Customs and Border Protection, at a Senate Committee hearing in May 2015. Texas Rep. Michael McCaul, chairman of the House Committee on Homeland Security, said in a January 2015 statement to right-leaning publication Daily Caller (founded by Fox News commentator Tucker Carlson and former Dick Cheney advisor Neil Patel) that "in our conversations with outside groups, experts and stakeholders, we learned that it would be an inefficient use of taxpayer money to complete the fence. … We are using that money to utilize other technology to create a secure border."

Who foots the bill?

On the campaign trail Trump's immigration reform plan called for impounding remittance payments derived from illegal wages, a controversial idea, and imposing increased visa and entry fees to the United States from Mexico unless the latter agrees to finance the wall. Trump is also pushing border taxes more broadly against trading partners, which could help finance the wall. According to a Government Accountability Office 2009 report, the cost to build 1 mile of fencing at the border averaged between $2.8 million and $3.9 million. But that figure may be low relative to costs for future sections of the wall. It's based only on the first 220 miles fenced and does not include other factors, such as topography, transportation logistics in harder-to-reach areas (i.e. road-building and earth and drainage work), labor costs, land acquisition costs and surveillance equipment.

"The first miles of fencing were in the easiest" places, said Marc Rosenblum, deputy director of the U.S. Immigration Policy Program at the Migration Policy Institute. These were fencing areas in or close to cities and accessible transportation, rather than deep in deserts or mountains. Additionally, the first miles were on public lands, while completing a border wall would require the government to acquire land from private holders. The GAO estimate for one difficult section of fencing near San Diego was $16 million.

I would build a great wall, and nobody builds walls better than me, believe me, and I'll build them very inexpensively — I will build a great, great wall on our southern border. And I will have Mexico pay for that wall. Mark my words. President Trump speaking last year on the campaign trail

One aspect of the wall debate more important than the cost is its worth. The migration expert Rosenblum said fencing in remote areas of the United States isn't likely to achieve the goal of a more secure border. "It's not necessary to have a pedestrian fence in places where the infrastructure doesn't support people walking toward the border," Vitiello said in his May Senate testimony.

Trump's Department of Homeland Security chief, John Kelly, said in recent Senate testimony, a "physical barrier will not do the job." He went on to say it can be part of a strategy. "If you build a wall, you would still have to back that wall up with patrolling by human beings, by sensors, by observation devices." Border walls work in densely populated areas — such as Israel's wall in the West Bank — where slowing down a person trying to illegally enter by five or 10 minutes can make a difference to border patrol. But when the migrant trying to enter is traveling over remote mountains and deserts for three days, using a fence to slow them down by a few minutes doesn't have the same effect — it borders on the trivial, Rosenblum said.

"There is a reason people don't build fences in the middle of nowhere; it doesn't change the enforcement profile in the middle of nowhere," the migration expert said. "The existing fence has worked because of where it is, near populated areas. Both Democrats and Republicans have testified that they have the fencing they need," Rosenblum said.

The actual cost for the rest of the border wall (roughly 1,300 miles) could be as high as $16 million per mile, with a total price tag of $15 billion to $25 billion. Rosenblum said the $15 billion low-end estimate is "probably an underestimate," because the parts that have yet to be fenced are the most difficult — the most dense and arid. At $16 million per mile and with 1,300 miles to secure, the estimated cost would be $12 billion, and the price of private land acquisitions and maintenance of fencing could push that total cost higher.

The U.S. government would have to pay to maintain the wall, which could cost as much as $750 million a year, according to an analysis conducted by Politico. And then if it wanted to man it with personnel, that would be an additional cost — border patrol has an operating budget of $1.4 billion for 21,000 agents. "The need to maintain, repair and replace outdated and aging fencing will continue to be an issue," Vitiello said during his Senate testimony given in May.

In addition to the 2009 GAO estimate of price per mile, more recent spending data is now available from the Department of Homeland Security (DHS). From fiscal 2007 through fiscal 2014, $5.9 billion in total appropriations was awarded by Congress to the Border Security Fencing, Infrastructure, and Technology Account (BSFIT). The account covers fencing, along with associated infrastructure, including roads to install and maintain fencing and cameras to monitor fencing. "This is actually the best way to think about the real costs of installing/maintaining fencing," Rosenblum said. "A fence is useless without a camera to tell you when someone has climbed over it."