WASHINGTON — The United States notched up a fourth straight month of declining deficits in July compared with a year ago, according to official data released Wednesday.

The US government's budget shortfall for the month was $129.4 billion, a decline of 22 percent from July 2010, the Treasury Department said.

The July gap was smaller than the average analyst forecast of $132 billion, but still marked the 34th consecutive month the US budget was mired in red.

In the first 10 months of fiscal 2011 that began on October 1, the US deficit was $1.1 trillion, a decline of 6.0 percent from the same period in fiscal 2010.

Revenues in the year to date were 8.0 percent higher, while spending rose a more modest 2.4 percent.

The 2011 budget deficit appears on track to come in below the record $1.29 trillion shortfall set in fiscal 2010, mainly due to bigger-than-expected revenues.

On Friday, rating agency Standard & Poor's took the unprecedented action of downgrading US credit from the top-notch AAA rating to AA-plus, citing a dangerously rising debt burden and the inability of battling politicians to forge a credible long-term deficit reduction plan.