(Adds reaction and additional background throughout)
WASHINGTON, March 23 (Reuters) - U.S. President Donald Trump made a surprising threat on Friday to veto Congress' newly passed $1.3 trillion spending bill, a move that raised the specter of a government shutdown ahead of a midnight deadline to renew funding for federal agencies.
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.
There was no immediate indication Trump would follow through on this threat. He was scheduled on Friday to fly to Florida for a weekend at his private resort.
Unless Trump backs down, Republican congressional leaders would need to scramble to find a way to avoid a government shutdown. One option is to call Trump's bluff and leave it to him to decide whether he is willing to contend with the political fallout of what would be the second government shutdown this year.
There was no immediate reaction from either Speaker Paul Ryan or Senate Leader Mitch McConnell. In a message sent more than an hour after Trump's threat, a twitter account run by Ryan's office said the House would not meet again until late on Monday.
"The government will only shut down if President Trump vetoes this bipartisan bill," Democratic Senator Chris van Hollen said in an interview on MSNBC. "No one's being fooled by the president's claim."
CAUGHT BY SURPRISE
Trump has been frustrated that Congress has not turned over funding to make good on his campaign promise to build a wall along the U.S.-Mexico border. The bill includes $1.6 billion for six month's of work on the project, although he had sought $25 billion for it.
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.
In a hastily arranged news conference on Thursday, Trump's budget director and top legislative aide had insisted he would sign the bill and tried to cast the budget 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.
At the White House on Friday, many aides were caught by surprise by the veto threat and had no immediate explanation for what prompted the threat.
Trump appeared to have tweeted from the White House residence, as there was no Marine guard posted outside the door of the West Wing, which is what happens when the president is in the West Wing.
White House spokeswoman Sarah Sanders was scheduled to brief reporters at 1 p.m. EDT (1700 GMT).
As the six-month spending deal was coming together, there had been 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."
Senator John Cornyn, the No. 2 Republican in the Senate, tweeted at Trump that the bill had "benefits" for "national security, border security, opioid crisis, infrastructure, school safety and fixing gun background check system" - all policies that Trump supports.
But the Conservative wing of Trump's party had panned the bill because of its spending increases. On Friday morning, Pete Hegseth, a Fox News host who Trump admires, said on the channel's morning show that it was a "swamp budget" and a "Mitch McConnell special," casting the budget as a win for Democrats.
Some deficit hawks cheered Trump's 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."
If Trump forces Congress to renegotiate a deal, he is likely to get one that is even less favorable on his priorities, said one Democratic aide.
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.
"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?" (Reporting by Richard Cowan and Steve Holland; additional reporting by Roberta Rampton, Amanda Becker, Susan Heavey and Patricia Zengerle; Editing by Bill Trott)