(Reuters) - Democrats and Republicans in Congress reached a deal on Tuesday to fund federal government activities through next March and eliminate any threat of agency shutdowns that could upset voters ahead of the November 6 presidential and congressional elections.

The deal, announced by House of Representatives Speaker John Boehner and Senate Majority Leader Harry Reid, would fund discretionary federal programs - from defense and foreign aid to education and medical research - at an annual rate of $1.047 trillion, the level specified in last year's debt limit deal.

The full House and Senate would still need to approve the measure by September 30, the end of the current fiscal year, when funding runs out. Congress will be in recess most of August and the first week of September.

If passed by Congress, the deal for a six-month spending extension eliminates one layer of difficult year-end bills Congress must grapple with just after the election as it deals with the "fiscal cliff" of expiring tax cuts, automatic spending cuts, a debt-limit increase and other fiscal deadlines that economists say if not averted could harm an already-weak economy.

It also would protect Republicans from being blamed for potential government shutdowns by demanding bigger spending cuts than already agreed to in last year's multi-year budget deal.

"This agreement reached between the Senate, the House and the White House provides stability for the coming months, when we will have to resolve critical issues that directly affect middle class families," Reid, a Democrat, said in a statement. "I hope that we can face the challenges ahead in the same spirit of compromise."