House and Senate leaders are nearing a temporary spending deal that would keep the federal government running for the first half of the next fiscal year, which will begin in October, aides in both parties said Monday, an effort to avoid a messy government shutdown fight on the eve of the November election.

The agreement could be announced by House Speaker John A. Boehner (R-Ohio) as soon as Tuesday, aides said.

The deal would come with two months to spare, an unusually early resolution of Washington’s annual budget fight for a Congress that has repeatedly run up against do-or-die deadlines and nearly forced shutdowns.

It is a sign that Republicans, in particular, understand the political peril of risking a budget fight in late September and would prefer a strategic retreat now, denying Democrats a chance to use a possible shutdown as a political cudgel at the height of the campaign season.

Under the deal, agency spending for the first half of the year would rise at a pace that would not exceed a $1.047 trillion limit that both parties agreed to in last summer’s debt deal, a senior House aide said.

That level represents a significant concession by conservatives, who had wanted to cut spending much more deeply.

House Budget Committee Chairman Paul Ryan (R-Wis.) had set agency spending levels at $1.028 trillion in the budget document he presented in the spring, a compromise with fiscal hard-liners who wanted to go even lower.

The House has spent months passing spending bills for different agencies geared toward the lower Ryan budget number, in the face of objections from Senate Democrats and a White House veto threat for any spending measure that cuts more deeply than the debt-ceiling agreement.

But some conservatives in recent weeks signaled that they could temporarily accept the higher levels, freeing Republican leaders to negotiate the deal. If the GOP is victorious in November, conservatives would aim to use their party’s control of the White House and the Senate to revisit spending in the new year.

A senior Senate Democratic aide called the negotiations between the two chambers “very productive.”

“The guys who spoil for a fight for the sake of a fight seem to be losing on this one,” he said.

Meanwhile, a senior GOP House aide said a deal would help Republicans.

“It would eliminate the possibility of Washington Democrats trying to force a shutdown fight in September, hoping to benefit politically,” he said.

The aides spoke on the condition of anonymity because the deal is not final and the talks are confidential.

A six-month resolution, which would expire at the end of March, would remove the basic discussion about keeping the government running from a much broader December fiscal debate about how to handle expiring tax cuts and deep automatic spending reductions set to take effect in January.

With basic agency spending settled, some Republicans might even push to skip a post-election lame-duck session should the GOP prevail in November, postponing major decisions until after control of the White House turned over in January.

In a letter sent to Boehner and Senate Minority Leader Mitch McConnell (R-Ky.) on July 18, a group of fiscal hawks led by Sen. Jim DeMint (R-S.C.) and Rep. Jim Jordan (R-Ohio) argued for quick passage of a spending deal to lessen Democrats’ leverage to push for higher taxes.

“The only way to protect the taxpayers from this premeditated mugging is for the House to pass, before the August recess, a fiscally responsible continuing resolution to extend federal operations well into the new year,” they wrote. “Taking the threat of a government shutdown off the table will allow a serious debate about tax and spending policy before the elections.”

Congressional leaders are likely to announce that they have reached an agreement in principle but leave passage of the deal until after Congress returns from its August recess. The timeline would allow some details and budget crunching to take place, but it also would provide a window for the deal to go awry if outside groups pressure Republicans to fight for deeper spending cuts.

Meanwhile, some lawmakers on the Appropriations Committee could spend August grumbling that simply extending this year’s spending policies for six months eliminates a key opportunity to review programs for effectiveness.