The news comes one week after President Trump said, "The United States will not be a migrant camp, and it will not be a refugee holding facility." He added, "Not on my watch."
Of the military's plan to build camps, Mattis said, "providing shelter for people without shelter — we consider that to be a logistics function that is quite appropriate."
The secretary described the plan to reporters on his plane as he traveled to Asia to visit his counterparts in China, South Korea and Japan.
Mattis compared the temporary camps to the military's response during a humanitarian crisis. "This is something that we can do," he said. "Again, whether it be refugee boat people from Vietnam, people who've been knocked out of their homes by a hurricane — absolutely, it's appropriate the military provide logistic support however it's needed."
The Trump administration has pledged "zero tolerance" for illegal immigration, and the president has shaped and reshaped the policy. Meanwhile, the U.S. government separated more than 2,500 children from their parents at the border over a recent weeks-long period.
The Department of Health and Human Services said over the weekend that it has been able to reunite 522 of those children with their families after they were taken into custody by U.S. Customs and Border Protection officials.
The family separation policy met with nearly universal outrage, and the president altered his policy last week. As a result, family units taken into custody after immigrating illegally are now subject to being detained together.
Trump's policy brought accusations that it was both illegal and cruel to separate migrant families — to put children into large holding facilities hundreds or thousands of miles away from their parents and caregivers. It also raised serious questions about what the government was doing to keep track of those kids, to ensure their parents could find them.
The backlash includes the website TrumpHotels.org, a satirical takeoff on the president's actual resort business website (whose address ends in .com). Instead of featuring photos of pools and golf courses, the site highlights images of detained children and adults living in fenced cages inside warehouse-like structures.
Republicans in Congress have pledged to pass a new immigration law aimed at addressing concerns about migrants' safety and legal protections, while also satisfying conservatives who want to clamp down on illegal border crossings.
The political process is playing out amid intraparty discord and mixed messages from the White House, as NPR's Kelsey Snell reports — including Trump's suggestion to ignore the issue until November, when he predicts Republicans will add to their majorities in Congress.
Over the weekend, Trump said via Twitter, "We cannot allow all of these people to invade our Country. When somebody comes in, we must immediately, with no Judges or Court Cases, bring them back from where they came. Our system is a mockery to good immigration policy and Law and Order."