WASHINGTON — The government is taking in more tax revenue as the economy improves, but not nearly enough to keep the federal budget deficit from exceeding $1 trillion for a third straight year.

The deficit for April dropped to $40.5 billion, half the imbalance from the same month last year, the Treasury Department said Wednesday. Tax receipts were up 45 percent last month compared to the same month one year ago.

Still, the deficit is on pace to grow to $1.4 trillion in this budget year, according to the Congressional Budget Office. That would be greater than last year’s $1.29 trillion deficit and nearly match the record $1.41 trillion deficit hit in 2009.

Through the first seven months of the budget year, the deficit has totaled $869.9 billion — a figure that just three years ago would have ranked as the highest ever for a full year.

Soaring deficits are putting pressure on Congress and President Barack Obama to agree on a long-term plan to trim federal spending.

The White House and Democrats want to trim the deficit through spending cuts and also by ending tax cuts for the wealthy, which were first passed when President George W. Bush was in office and later extended by Obama.

Republicans reject that approach, saying it amounts to a tax increase. Their plan would focus exclusively on cutting spending. They have also proposed further tax cuts for the wealthiest Americans.

A decade ago, it seemed the federal budget was heading in the opposite direction. The government had a surplus of $127 billion in 2001 when President George W. Bush took office and was projected to run surpluses totaling $5.6 trillion over the next decade.

But by 2002, the country was back in the red. The deficits grew after Bush won approval for the broad tax cuts, pushed a major drug benefit program for seniors — which wasn’t offset with revenue to pay for it — and entered the country into wars in Iraq and Afghanistan.

In 2008, Bush’s last full year in office, the deficit had grown to $454.8 billion, a record at the time. And when the economy soured, it jumped into the $1 trillion-plus range.

The Bush administration pushed a $700 billion bailout program in 2008 to rescue the nation’s banks, financial firms and automakers. The following year, the Obama administration continued the bailouts and also backed a $787 billion stimulus program to boost the economy.

Higher spending for unemployment insurance and food stamps, and the sharp contraction in tax revenues, also widened the deficit. And it grew even more this year after Obama and congressional Republicans signed off on a deal that extended the Bush tax cuts for two years and also reduced Social Security payroll taxes for one year.

The monthly reports this year have shown that the revenue losses are turning around. Unemployment, while still high, has been declining. More people working means more tax revenue for the government.

Through April, government revenues totaled $1.31 trillion, up 9.2 percent from the seven months through April of 2010. The increase included the big jump in income tax payments received by the government from individuals filing in April and also a gain in corporate tax payments.

Government spending totaled $2.18 trillion through April, a 9 percent increase over the same period a year ago. One of the fastest-rising categories was interest on the government’s debt held by the public, which rose 13.1 percent to $139.3 billion through the first seven months of this budget year.

Last month, Standard & Poor’s lowered its long-term outlook for the federal debt from “stable” to “negative.” The credit rating agency said there could be serious consequences if lawmakers failed to reach a deal to control the ballooning deficits.

The issue is expected to come to a head over the next few months as Congress debates legislation to raise the government’s $14.3 trillion borrowing limit. Treasury Secretary Timothy Geithner has said by Aug. 2 he will run out of maneuvering room to avoid a default on the national debt.

But House Speaker John Boehner said this week that any legislation to raise the debt ceiling should be accompanied by spending cuts larger than the amount of the permitted increase in the debt.