Donald Trump says he will close down the US government if necessary to build his wall along the Mexico border.
The president told supporters at a "Make America Great Again" rally in Phoenix, Arizona, that the opposition Democrats were being "obstructionist".
During the 80-minute speech, he also took aim at the media, blaming them for giving far right groups "a platform".
But he selectively quoted his initial response to violence at a far-right rally that left one woman dead.
He omitted the much-criticised claim that "many sides" had to shoulder the blame for violence in Charlottesville, Virginia.
What did he say about the wall?
President Trump wants Congress to finance his controversial plan to build a "big, beautiful" wall along the United States' border with Mexico to keep out illegal immigrants.
But Republicans will need the support of Democrats to secure funding for the wall in a government spending bill, which they are unlikely to get.
In his speech, Mr Trump said the Democrats were "putting all of America's safety at risk" by opposing the wall. He said immigration officers who worked in the area said it was "vital" to stem the flow of illegal immigrants.
He said that, if it came to it, he would risk a government shutdown - which is what happens when legislation funding the federal government cannot be passed by Congress and non-essential services stop.
"Now the obstructionist Democrats would like us not to do it, but believe me if we have to close down our government, we are building that wall," Mr Trump said, adding that "the American people voted for immigration control".
If President Trump wants a government shutdown all he has to do is refuse to sign a funding bill sent to him by Congress.
Capitol Hill is set to debate a new budget measure this autumn, and unless it is passed federal operations will be in limbo by 1 October.
Trump's 'all or nothing' approach
By James Cook, BBC North America correspondent, Phoenix
Donald Trump's signature campaign promise - to "build that wall" - epitomised his appeal to the nation, an apparently simple solution to a problem freighted with racial and economic undertones.
Not only that but it would be free! Mexico would pay, as Mr Trump and his cheering crowds repeatedly insisted.
But it turns out that governing is harder than campaigning.
Construction of prototypes near San Diego in California - which had been scheduled for this summer - has been delayed until at least December by a legal challenge from one rejected bidder.
Ranchers, environmentalists and some businesses on the border have raised objections to the plan, while one Republican congressman in Texas, Will Hurd, has even described the wall as the most expensive and least effective way to secure the border.
Mexico, needless to say, is not keen to write a cheque.
Faced with the need to win over doubters on the detail, and explain why this would be a lot of money well spent, Mr Trump has instead chosen to raise the stakes with an "all or nothing" approach.
This should not come as a surprise.
What did he say about Charlottesville?
President Trump attacked the media in the campaign-style speech, saying reporters had misrepresented his "perfect" words in the wake of the violence in Charlottesville, where Heather Heyer was killed after a car ploughed into a crowd of people protesting against far-right demonstrators including neo-Nazis.
He accused "truly dishonest people in the media and the fake media" of "trying to take away our history and heritage" because, he said, they "don't like our country".
He quoted his first public response to the violence on 12 August, which was criticised by both Republicans and Democrats for not explicitly condemning the far-right.
"This is what I said on Saturday: 'We're closely following the terrible events unfolding in Charlottesville, Virginia,' - this is me speaking. 'We condemn in the strongest possible terms this egregious display of hatred, bigotry and violence.' That's me speaking on Saturday, right after the event," he said.
But his full quote was: "We condemn in the strongest possible terms this egregious display of hatred, bigotry and violence on many sides, on many sides."
Separately, the UN Committee on the Elimination of Racial Discrimination has criticised the US for what it said was a "failure at the highest political level" to reject "racist violent events".
Referring to Charlottesville, the committee said it was issuing a rare "early warning", which has been used in recent years in countries including Burundi, Iraq, Nigeria and the Ivory Coast.
What other topics came up?
- Nafta: The US, Mexico and Canada have begun talks on revising their trade deal, and negotiators are due to meet again on 1 September. But Mr Trump said he thought he would "probably end up terminating Nafta"
- North Korea: He sounded hopeful about a reduction in tensions. Referring to North Korean leader Kim Jong-un, Mr Trump said: "I respect the fact that he is starting to respect us." He added: "And maybe - probably not, but maybe - something positive can come about"
- Sheriff Joe Arpaio: The US president hinted he would pardon the controversial former Arizona sheriff, who rose to national prominence because of his tough stance against illegal immigration. He said that Joe Arpaio - who was found guilty of criminal contempt in July over his detention of migrants - "is going to be just fine", but he would not yet formally pardon him because "I don't want to cause any controversy"
What has the reaction been?
Responding to the speech, the former National Intelligence director James Clapper told CNN that he was questioning Donald Trump's "fitness" for office.
"I also am beginning to wonder about his motivation for it," he said, adding he found the rally "downright scary and disturbing".
Ruben Gallego, a Democratic Party congressman in Arizona, said it was the worst-ever speech by a US president. "It was all about him, it was not about the country," he told the BBC.
A former British ambassador to the US, Peter Westmacott, said he saw parallels with the establishment of Nazi Germany in 1933.
Allow Twitter content?
But Trump supporters were pleased.
"President Trump did an amazing job tonight. His message is uniting our great nation!", tweeted Ryan Fournier, the head of Students for Trump.
White Nationalist Richard Spencer tweeted: "Trump has never denounced the Alt-Right. Nor will he."
Was the rally peaceful?
While Mr Trump's comments were met with cheers inside the conference centre, anti-Trump protesters who had gathered outside the rally clashed with police after the rally had finished.
A police spokesman in the city said at least four arrests were made after protesters threw bottles and rocks.