WASHINGTON — President Trump threatened on Friday to keep the federal government partly closed for “months or even years” if he did not get $5.6 billion for his wall at the southern border, and he warned that he was considering declaring a national emergency to build it without congressional approval.

Mr. Trump and Democratic leaders emerged from a two-hour meeting in the White House Situation Room without a deal to reopen government agencies that have already been shuttered for two weeks, and the two sides offered sharply contrasting views of where they stood. By day’s end, the two sides appeared to be still locked in a stalemate.

Democrats called the meeting “contentious” while the president and Republican leaders in the House called it “productive.” And while Mr. Trump announced that he had assigned Vice President Mike Pence to lead a “working group” to negotiate with Democrats over the weekend, Democrats said the phrase “working group” was never discussed.

“We told the president we needed the government open,” Senator Chuck Schumer of New York, the Democratic leader, told reporters outside the White House. “He resisted. In fact, he said he’d keep the government closed for a very long period of time, months or even years.”