* Bipartisan agreement needs approval in House and Senate
* Plan would extend U.S. debt ceiling
* Trump tweets support (Updates with opposition to deal, Pelosi marathon speech, Trump tweet)
WASHINGTON, Feb 7 (Reuters) - U.S. Senate leaders, in a rare display of bipartisanship, reached a two-year budget deal on Wednesday to raise government spending by almost $300 billion, attempting to curb Washington's fiscal policy squabbling but also widening the federal deficit.
The agreement was announced by the Republican and Democratic leaders of the Senate and backed by House of Representatives Speaker Paul Ryan, but House Democratic leader Nancy Pelosi spoke out against it in a marathon speech on the House floor.
As a deadline neared on Thursday for passage of a short-term spending bill to avert a government shutdown, high-stakes votes were expected in both chambers of Congress.
The timing of the votes was unclear as Pelosi ended her eight-hour speech early on Wednesday evening.
The deal appeared to have bipartisan support in the Senate, but it could face resistance among conservative House Republicans concerned about the deficit impact.
If the Senate deal is approved, it would then go to Republican President Donald Trump for him to sign into law.
Trump, who campaigned for the presidency on a promise to boost military spending, gave his support to the budget deal in a tweet on Wednesday night. "Republicans and Democrats must support our troops and support this bill!" Trump said.
The Senate deal would lift caps first imposed in 2011 on defense funding and domestic spending. It would also extend the federal government's debt ceiling until March 2019, defusing a contentious issue and putting off for more than a year the risk of a debt default, which had loomed next month.
Along with tax cuts backed by Trump and pushed through Congress by Republicans, the spending deal would add to the deficit, which hit $666 billion in fiscal 2017. A private Washington budget watchdog group projected the deficit was on track to exceed $1 trillion in 2019.
Pelosi said she would not back the agreement unless Ryan committed to allow a vote on bipartisan legislation to protect from deportation hundreds of thousands of "Dreamers," young people brought illegally to the United States as children.
Pelosi set the record for the longest continuous speech in House history, reading from letters of Dreamers pleading for the legislation.
Earlier, Republican and Democratic rivals in the Senate said they had reached a breakthrough after months of bickering over spending priorities.
"This bill is the product of extensive negotiations among congressional leaders and the White House," Senate Majority Leader Mitch McConnell, a Republican, said on the Senate floor.
His Democratic counterpart, Chuck Schumer, said the deal "should break the long cycle of spending crises that have snarled this Congress and hampered our middle class."
It would also extend the debt ceiling for a year and finance disaster relief, healthcare and infrastructure programs as well as boost funding for efforts to address an opioid crisis in the country, the Senate leaders said.
The Treasury Department has warned that without an extension in the debt ceiling, the government would run out of borrowing options in the first half of next month, risking an unprecedented debt default.
The deal, if approved, would also fund the federal government until March 23, averting a second shutdown this year and giving lawmakers six weeks to resolve their differences over immigration policy and find agreement on a full-year budget.
White House legislative affairs director Marc Short said the deal would increase government spending by "just shy" of $300 billion over two years.
A senior congressional aide said that amount of additional spending would not be offset by any spending cuts or new tax revenue, meaning an increase in the federal deficit.
Some conservative groups were furious.
"This really is the moment where it has become clear that despite record levels of debt and approaching trillion dollar deficits, Congress has stopped caring about what they're doing to the fiscal health of the country," said Maya MacGuineas, head of the Committee for a Responsible Federal Budget, a group that advocates for long-term fixes to Washington's debt problems.
In financial markets, yields on benchmark 10-year notes rose on news of the budget deal, on expectations of higher growth and potentially greater Treasury supply.
A large uptick in bond issuance is expected after Congress raises the debt ceiling, which along with higher inflation expectations has weighed on bonds in the past week.
A congressional source familiar with the agreement said it would increase non-defense spending by $131 billion and include $20 billion for infrastructure spending. It also would extend funding for the Children's Health Insurance Program (CHIP) for 10 years instead of the current six, the source added.
The government was shut down for three days last month after Democrats sought to have a spending bill include protections for the Dreamers.
Trump has said he is open to a deal for the Dreamers but only if he is able to build a wall on the U.S.-Mexico border and tighten up on immigration policy.
Trump threatened on Tuesday to upend budget talks by saying he would welcome a government shutdown if Congress were not able to agree to changes in immigration law that he said would prevent criminals from entering the country.
(Additional reporting by David Morgan, Susan Heavey and Doina Chiacu in Washington and April Joyner in New York; Writing by Alistair Bell; Editing by Will Dunham and Peter Cooney)