(Adds comments from lawmakers)
WASHINGTON, March 23 (Reuters) - U.S. President Donald Trump made a surprising threat to veto Congress' newly passed $1.3 trillion spending bill, a move that raised the specter of a possible government shutdown ahead of a midnight Friday deadline to keep federal agencies open.
In a tweet on Friday morning Trump said he was displeased about immigration issues in the bill, even though the White House had given assurances on Thursday that he would sign it. Lawmakers in the Senate and House of Representatives, which both are dominated by Trump's fellow Republicans, had left Washington after passing the measure.
"I am considering a VETO of the Omnibus Spending Bill based on the fact that the 800,000 plus DACA recipients have been totally abandoned by the Democrats (not even mentioned in Bill) and the BORDER WALL, which is desperately needed for our National Defense, is not fully funded," Trump wrote.
Trump has sought to make good on his campaign promise to build a wall along the U.S.-Mexico border and the bill includes $1.6 billion for six month's of work on the project, although he had sought $25 billion for it. In a tweet on Thursday he had seemed not to have a problem with partial funding because "the rest will be forthcoming."
Trump also has been at odds with Democrats in Congress over the fate of Dreamer immigrants - those brought to the United States illegally when they were children.
At the White House, many aides were caught by surprise by the veto threat and were scrambling for answers. There was no immediate explanation for what prompted the threat other than Trumps frequent complaints that he felt Democrats were unwilling to move his way on immigration issues.
Trump appeared to have tweeted from the White House residence, as there is no Marine guard posted outside the door of the West Wing, which is what happens when the president is in the West Wing.
A White House official would say only that its the presidents tweet and could not answer further questions. Trump is scheduled to leave later in the day for a weekend at his private resort in Palm Beach, Florida.
There was no immediate comment from Republican leaders in Congress.
THREAT OR BLUFF?
As the six-month spending deal was coming together, there were reports Trump had balked at the deal and had to be persuaded by Republican Speaker Paul Ryan to support it.
Only minutes before Trump's threat, Ryan had tweeted: "Our men and women in uniform have earned a pay raise. Thats why yesterday, we voted to provide the biggest pay raise for our troops in 8 years."
Conservatives and deficit hawks in Trump's party had panned the bill because of its spending increases. Some cheered his threat to veto it.
"Please do, Mr. President," Republican Senator Bob Corker said on Twitter. "I am just down the street and will bring you a pen. The spending levels without any offsets are grotesque, throwing all of our children under the bus."
Democratic lawmakers said Trump created his own crisis by canceling the Deferred Action for Childhood Arrivals (DACA) program that gives work permits to certain young immigrants and protects them from deportation. The decision is currently tied up in court cases.
Trump had agreed to extend the program if Congress agreed to sweeping changes in immigration laws and provided $25 billion to build the wall and increase border security. Democrats rejected the plan.
"NOW you care about the Dreamers Mr. President?" Democratic Representative Jan Schakowsky said on Twitter. "Six months after throwing their lives into chaos? Is this a cruel joke?"
In a hastily arranged news conference on Thursday, Trump's budget director and top legislative aide insisted he would sign the bill and tried to cast the $1.6 billion in funding for border security as a downpayment on Trump's wall pledge.
"It does a lot of what we wanted - not everything we wanted - but a lot of what we wanted on immigration," White House budget director Mick Mulvaney told reporters. (Reporting by Richard Cowan and Steve Holland; additional reporting by Roberta Rampton, Susan Heavey and Patricia Zengerle; Editing by Bill Trott)