The American economy shrank at the end of last year for the first time since the recession ended, according to new government data, as deep cuts in federal spending torpedoed what otherwise looked to be a modest recovery.

Consumers did their part, spending more and opening their wallets for bigger-ticket items such as automobiles. Companies invested in new equipment and software. Housing continued to climb.

But those gains were overshadowed by the massive decline in government spending, especially in defense. The result was a 0.1 percent annualized dip in the nation’s gross domestic product. The report highlighted the contrast between what appears to be a slowly healing private sector and a public sector still buffeted by budget cuts.

The economy was “being pulled in opposite directions . . . and ending up going nowhere,” said Richard Moody, chief economist at Regions Financial Corp.

The biggest threat to the recovery now appears to be Washington, with lawmakers gearing up for another round of debates over spending cuts and raising the nation’s debt ceiling. Wednesday’s GDP report served only to harden the battle lines between Republicans who believe significant spending cuts are necessary to balance the federal budget over the next decade and Democrats who argue they will stunt growth.

“Do we make progress in a balanced way on our deficits? Or do we, you know, inflict harm on our economy here in Washington at a time when our economy is actually showing very positive signs?” White House press secretary Jay Carney said in a daily news briefing Wednesday.

But Sen. John Cornyn (Tex.), the No. 2 Republican in the Senate, called the idea that economic growth relies on government spending “a Keynesian pipe dream.” The best thing Washington can do for the economy is to rein in the deficit, GOP leaders said.

“Only the private sector can lead a robust, sustained recovery,” said William Allison, spokesman for House Budget Committee Chairman Paul Ryan (R-Wis.). “Government can never take its place.”

Fourth-quarter economic activity was far below the 1.1 percent annual growth rate economists had predicted. Exports fell at a rate of 5.7 percent in the fourth quarter, reflecting the slowdown in Europe. Businesses also drew down their inventories after unusually high stockpiling in the previous period. That reduced economic growth by 1.27 percentage points.

But perhaps the biggest surprise was the size of the drop in federal spending: 15 percent at an annual rate during the fourth quarter. Defense spending suffered an even bigger decline, dragging down growth by 1.3 percentage points. Many agencies began adopting contingency plans, instituted hiring freezes and delayed projects in anticipation of widespread budget cuts — all of which depress spending.

Still, economists said the decline looks especially dramatic because government spending had jumped more than usual in the previous quarter. That may have been a reflection of government agencies and private contractors shifting spending earlier in the year in anticipation of budget cuts, boosting third-quarter growth at the expense of the fourth. Economists are hopeful that federal and defense spending will return to more normal levels over the next few months, provided Washington can reach a deal on budget cuts and the deficit.

“I don’t really read anything into the number,” said Mark Zandi, chief economist for Moody’s Analytics. “I don’t think anything has fundamentally changed in the economy.”

GDP in the private and government sectors.

The negative numbers mask the broad-based growth in the private sector. Consumer spending picked up to a 2.2 percent annual pace as incomes enjoyed a bump from higher dividend payments. Housing rose at a 15.3 percent rate, and businesses increased investments in equipment and software after curtailing them during the third quarter.

For the entire year, GDP grew at a 2.2 percent rate, a faster pace than in 2011.

“The good thing about this recovery is that it keeps on keeping on, and the bad thing . . . is that it doesn’t take off,” said Justin Wolfers, a professor of economics and public policy at the University of Michigan.

The country is entering 2013 on a weaker footing than expected, making it more vulnerable to the whims of Washington. Nathaniel Karp, chief economist for BBVA Compass, said it is impossible to isolate the consequences of continuing cuts in federal spending. Eventually, they will spill over into the rest of the economy.

“Hopefully this is happening because you’re adjusting your long-term financial stability,” he said. But, he added, “that is a price you have to pay now.”

Federal Reserve officials Wednesday alluded to the downbeat GDP report as they wrapped up their two-day meeting to set monetary policy. The Fed said economic activity “paused” in recent months but cited weather and “other transitory factors” as the main culprits. It maintained its pledge to help stimulate the economy by purchasing $85 billion in long-term securities each month and keeping its target interest rate at a historic low.

Stock markets seemed to shrug off the news that the economy contracted but began falling after the Fed released its comments. The major U.S. indexes ended the day down more than 0.3 percent.

Economists also cautioned that Wednesday’s report was the government’s first crack at measuring economic activity in the fourth quarter and that the data are often revised. An updated report is slated for release Feb. 28, and many economists predicted it will be more upbeat.

But Steve Ricchiuto, chief economist at brokerage firm Mizuho Securities, was less optimistic.

“The preliminary number is negative,” he said. “ . . . But the recovery is supposedly gaining momentum. Sorry, I don’t see it.”

Lori Montgomery and Zachary A. Goldfarb contributed to this report.