Donald Trump has vowed to close down government if that is what it takes to build his wall along the Mexico border.
The US 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”.
Mr Trump also said he thought he would “probably end up terminating Nafta”, the trade deal with Mexico and Canada.
On North Korea, the president sounded a hopeful note about the possibility of a reduction in tensions over Pyongyang’s missile tests and nuclear programme.
Referring to North Korean leader Kim Jong-un, Mr Trump said: “I respect the fact that he is starting to respect us”.
“And maybe – probably not, but maybe – something positive can come about,” he added.
But while his 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.
Police deployed tear gas after the protesters threw bottles and rocks, Reuters news agency reported.
President Trump began and finished his speech by urging the American people to come together.
But he quickly turned on familiar foes, beginning with the media which he said had misrepresented his “perfect” words in the wake of the violence at a far-right rally in Charlottesville , which left one woman dead.
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”.
Mr Trump also read out part of a speech he had given a few hours after Charlottesville, but left out the controversial claim that “both sides” had to shoulder the blame.
Mr Trump’s attention then turned to immigration, and to the Democrats who he said were “putting all of America’s safety at risk” by opposing the wall he wants to build along the US’s southern border with Mexico.
He said immigration officers who worked in the area said it was “vital” to stem the flow of illegal immigrants.
Mr Trump concluded: “If we have to close down government, we are building that wall.”
Mr Trump also used the rally to hint he would pardon controversial former Arizona sheriff Joe Arpaio, a man who rose to national prominence because of his tough stance against illegal immigration.
He told the crowd Mr Arpaio – who was found guilty of criminal contempt in July – “is going to be just fine”, but would not formally pardon him at the moment because “I don’t want to cause any controversy”.
His comments directly contradicted those of White House spokeswoman Sarah Sanders, who said on Tuesday “there will be no discussion of that today”.
Mr Arpaio, 85, was found to have violated a judge’s 2001 order that he cease detaining migrants who are not suspected of having committed a state crime.