Congressional Republicans and Democrats forged a hard-won agreement Sunday night on a huge $1 trillion plus spending bill that would fund the day-to-day operations of virtually every U.S. federal agency through September, denying President Donald Trump funding for a border wall and rejecting his cuts to popular domestic programs.

Aides to lawmakers involved in the talks disclosed the agreement Sunday night after weeks of negotiations. The bill was made public in the pre-dawn hours Monday.

The catchall spending bill would be the first major piece of bipartisan legislation to advance during Trump's short tenure in the White House. While losing on the wall along the U.S.-Mexico border, Trump won a $15 billion down payment on his request to strengthen the military.

The measure funds the remainder of the 2017 budget year, through Sept. 30, rejecting cuts to popular domestic programs targeted by Trump, such as medical research and infrastructure grants.

Successful votes later this week would also clear away any remaining threat of a government shutdown — at least until the Oct. 1 start of the 2018 budget year. Trump has submitted a partial 2018 budget promising a 10 per cent increase for the Pentagon, financed by cuts to foreign aid and other non-defence programs that negotiators on the pending measure protected.

Democrats were quick off the mark to praise the deal.

"This agreement is a good agreement for the American people, and takes the threat of a government shutdown off the table," said Senate Minority Leader Chuck Schumer, a New York Democrat, a key force in the talks.

"The bill ensures taxpayer dollars aren't used to fund an ineffective border wall, excludes poison pill riders, and increases investments in programs that the middle class relies on, like medical research, education and infrastructure."

Trump said at nearly every campaign stop last year that Mexico would pay for the 3,219-kilometre border wall, a claim Mexican leaders have repeatedly rejected. The administration sought some $1.4 billion in U.S. taxpayer dollars for the wall and related costs in the spending bill, but Trump later relented and said the issue could wait until September.

Trump, however, obtained $1.5 billion for border security measures such as more than 5,000 additional detention beds, an upgrade in border infrastructure and technologies such as surveillance.

U.S. immigration officers conduct an operation in Atlanta, Ga, U.S. in February. During talks the White House backed away from language to take away grants from 'sanctuary cities' that do not co-operate with federal immigration authorities. (Bryan Cox/ICE/Reuters)

The measure is assured of winning bipartisan support in votes this week; the House and Senate have until midnight Friday to pass the measure to avert a government shutdown. It's unclear how much support the measure will receive from Republican conservatives and how warmly it will be received by the White House.

Republicans are also eager to move on to other issues such as overhauling the tax code and reviving their moribund effort to repeal the Affordable Care Act, President Barack Obama's health care law.

"The omnibus [spending bill] is in sharp contrast to President Trump's dangerous plans to steal billions from lifesaving research, instead increasing funding for the NIH [National Institutes of Health] by $2 billion," House Minority Leader Nancy Pelosi, a California Democrat, said in a statement.

"Now, the members of our caucus will assess the whole package and weigh its equities," she added.

House Minority Leader Nancy Pelosi of Calif. called the deal a 'sharp contrast' from U.S. President Donald Trump's plans to cut medical research. (Manuel Balce Ceneta/Associated Press)

Relief for Puerto Rico

While the measure would peacefully end a battle over the current budget year, the upcoming cycle is sure to be even more difficult. Republicans have yet to reveal their budget plans, and battles between Trump and Congress over annual agency budgets could grind this summer's round of spending bills to a halt.

Among the final issues resolved was a Democratic request to help the cash-strapped government of Puerto Rico with its Medicaid burden, a top priority of Pelosi's. She and other Democrats came up short of the $500 million or so they had sought but won $295 million for the island, more than Republicans had initially offered.

Democrats were successful in repelling many conservative policy "riders" that sought to overturn dozens of Obama-issued regulations. Such moves carry less urgency for Republicans now that Trump controls the regulatory apparatus.

House Republicans succeeded in funding another round of private school vouchers for students in Washington, D.C.'s troubled school system.

Republican leaders demurred from trying to use the must-do spending bill to "defund" Planned Parenthood. The White House also backed away from language to take away grants from "sanctuary cities" that do not share information about people's immigration status with federal authorities.

Trump cuts rejected

Democrats praised a $2 billion funding increase for the National Institutes of Health — a rejection of the steep cuts proposed by Trump — as well as additional funding to combat opioid abuse, fund Pell Grants for summer school, and additional transit funding. Senate forces, led by Majority Leader Mitch McConnell, a Kentucky Republican, and several Appalachia region Democrats, won a provision to extend health care for 22,000 retired Appalachian coal miners and their families.

Democratic votes will be needed to pass the measure even though Republicans control both the White House and Congress. The minority party has been actively involved in the talks, which appear headed to produce a lowest common denominator measure that won't look too much different than the deal that could have been struck on Obama's watch last year.

For instance, the measure contains a $2 billion disaster aid fund, $407 million to combat Western wildfires, and additional grants for transit projects, along with $100 million in emergency funding to fight the nation's opioid crisis.

The measure also taps $68 million to reimburse New York City and other local governments for unexpected costs involved in protecting Trump Tower and other properties, a priority of lawmakers such as Rep. Nita Lowey, a New York Democrat.