WASHINGTON — President Donald Trump threatened Friday to keep the government shut down for months or even years if he doesn't get money for his border wall and said he is considering declaring a national emergency to build the barrier if necessary.

"We can call a national emergency because of the security of our country," he said in the White House Rose Garden after a closed-door negotiating session with congressional Democratic and Republican leaders. "I may do it. We can call a national emergency and build it really quickly."

One way the president could free up the bulk of the money he wants for the wall is through a transfer of up to $4 billion in Defense Department funds. Technically, that would require the Defense secretary to determine that the move is in the national interest and to notify Congress — a move that in the past has meant sign-off from top House and Senate lawmakers, but that Trump might try to execute without that assent.

The message about a long-term shutdown was delivered during the private meeting.

"He said he’d keep the government closed for a very long period of time...months or even years," Senate Minority Leader Chuck Schumer told reporters when the negotiations broke. "It's very hard to see how progress will be made unless they open up the government."

Trump later confirmed the exchange in a Rose Garden press conference that lasted over an hour.

"I did. I did. Absolutely I said that," he said.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

"I don’t think it will" come to that, Trump said, calling it a "productive" meeting. "We've come a long way," he said, though he offered little in the way of details.

Several federal agencies ran out of funding authority Dec. 21 as Congress and Trump failed to agree to spending bills to keep them operating. They have remained shuttered since then amid a battle between the president and congressional Democrats over whether to provide money — and how much — for a wall along the nation's border with Mexico.

The parts of the federal government that are funded are only authorized through the end of September, and it would take new agreements between Congress and the president to keep them operating beyond them.

Asked whether he was still "proud" to claim responsibility for the shutdown, as he said he would be before the deadline for renewing funding, Trump shifted his stance a bit.

"I’m proud of doing what I’m doing," he said. "You can call it 'the Schumer' or 'the Pelosi' or 'the Trump shutdown.' Doesn’t make any difference to me. Just words."

Trump has insisted on getting $5.6 billion included in a spending package that would re-open the closed agencies, while House Speaker Nancy Pelosi has said he will get "nothing for the wall."

In December, the Senate unanimously passed a bill that would have spent more than $1 billion on border security, and the House passed a competing measure that would have fulfilled Trump's request. The two chambers, then both run by Republicans, deadlocked and the bills died with the end of the last Congress on Thursday.

This week, House Democrats passed legislation that would reopen the closed agencies without providing money for the border wall. Senate Majority Leader Mitch McConnell, R-Ky., has said the measures will not be taken up in that chamber.

Pelosi told reporters that the meeting produced progress in at least one way.

"How do you define progress in a meeting? When you have a better understanding of each other’s position, when you eliminate some possibilities," she said. "If that’s a judgment, then we made some progress."

Sen. Jack Reed, D-R.I., ranking member on the Senate Armed Services Committee, said the president's 'national emergency' plan would be a non-starter.

“Declaring a trumped up national emergency in order to skirt Congressional approval is wrong," he said in a Friday statement. "...Defense spending is for national defense, not the Trump campaign’s political wish list. I will work with colleagues on both sides of the aisle to block any attempt to take money that has been dedicated for our troops and redirect it to construction of a wasteful, ineffective wall."

On his return to the Capitol, McConnell said White House and congressional teams would work through the weekend to try to strike a deal to re-open the closed parts of the government.

"The president is going to designate his experts and ask each of us to designate our experts to meet over the weekend to see if they can reach an agreement to then kick up to us for a final decision," he said.

Trump said he hoped that process would yield progress, and acknowledged that the meeting Friday didn't always go smoothly.

"I think it may have been somewhat contentious," he said.