President Trump sought to bolster his case that he could invoke emergency powers to build a border wall by selectively quoting a Democratic congressman Monday who said that doing so would be a terrible use of resources and probably to prompt a court challenge.

In a morning tweet, Trump referenced a Sunday talk show appearance by Rep. Adam Smith (D-Wash.), who was asked whether the president has the authority to declare a national emergency and direct the military to build the wall — a prospect Trump has raised several times as a spending stalemate with Congress continues.

“Congressman Adam Smith, the new Chairman of the House Armed Services Committee, just stated, ‘Yes, there is a provision in law that says a president can declare an emergency. It’s been done a number of times,’ ” Trump wrote.

Trump accurately quoted part of Smith’s answer given in an interview on ABC News’s “This Week,” but the president omitted what the Democrat said next.

Smith said that such powers have been used primarily to build facilities in Afghanistan and Iraq, two countries where the United States has fought wars.

“In this case, I think the president would be wide open to a court challenge saying, ‘Where is the emergency?’ You have to establish that in order to do this,” Smith told host George Stephanopoulos. “But beyond that, this would be a terrible use of Department of Defense dollars.”

Smith also voiced objections to the idea Friday, when Trump floated it during a Rose Garden news conference as a way forward on his marquee campaign promise without congressional consent.

And Smith renewed his objections Monday during an appearance on CNN.

“I think it would be a huge mistake to declare a national emergency. There is no national emergency,” the Democrat said when asked about Trump’s tweet. “He’d be challenged in court because clearly there is no emergency.”

Smith added that he considers the wall envisioned by Trump “a colossal waste of money for a crisis that doesn’t exist.”

During the same interview, Smith criticized Trump for his evolving statements about how quickly and under what conditions he will withdraw U.S. troops from Syria.

“This is very similar to the border issue. It shows that our president literally doesn’t know what he’s doing,” Smith said. “He’s changing course like a drunken sailor. There’s no thought behind it.”

In his Monday tweet, Trump seemed to indicate that his preference would be to secure border wall funding from Congress and end a partial government shutdown that has dragged on for more than two weeks.

After selectively quoting Smith, he wrote: “No doubt, but let’s get our deal done in Congress!”