WASHINGTON —The war in Iraq is officially over. The costs will go on.

Eight years of dodging improvised explosive devices, repelling insurgent ambushes and quelling sectarian strife already has drained the United States of more treasure than any conflict in the nation’s history except World War II.

Even though the last U.S. combat troops have left Iraq, American taxpayers will face decades of additional expenses, from veterans’ health care and disability benefits to interest on the debt accumulated to finance the war.

“Those costs are going to build for years,” said Todd Harrison, a senior fellow at the Center for Strategic and Budgetary Assessments, a Washington-based research group.

That burden will come amid growing concern about the federal government’s debt, with cuts to popular programs such as Medicare and to national defense being debated. Spending so far on the war and related interest payments make up about a tenth of the U.S. Treasury’s $10.4 trillion in publicly held debt.

Direct federal spending on the war through 2012 will reach $823 billion, surpassing the $738 billion in inflation-adjusted dollars the U.S. spent on the Vietnam War, the Congressional Research Service estimated in a March 29 report. Only World War II had a higher direct cost, $4.1 trillion, in current dollars.

Not counted in that is the interest of more than $200 billion the federal government has already had to pay on the resulting debt, said Linda Bilmes, a senior lecturer in public finance at Harvard’s Kennedy School of Government.

Bilmes also estimates the price over the next 40 years of health care and disability compensation for veterans of the Iraq and Afghanistan conflicts will be almost $1 trillion.

“The veterans’ costs in particular will dwarf the other budget costs,” said Bilmes, who was an assistant commerce secretary under President Bill Clinton.

By any measure, the price of the Iraq conflict has far outstripped forecasts by President George W. Bush’s administration as it made the case to go to war. Then-White House budget director Mitch Daniels and Defense Secretary Donald Rumsfeld projected the U.S. would spend $50 billion to $60 billion and said they believed part of that would be defrayed by other countries.

Rumsfeld rejected as “baloney” a September 2002 comment made by Lawrence Lindsey, then director of Bush’s National Economic Council, that the war might require $100 billion to $200 billion in spending. Lindsey was forced out of his position several months later.

Still, while the conflict turned out to be among the most expensive in the nation’s history, the size of the U.S. economy is now larger than in earlier wars and so is the nation’s capacity to bear the financial load.

At the peak of spending on Iraq in 2008, direct costs represented 1 percent of U.S. gross domestic product. The portion of GDP devoted to war expenditures during the peak year of spending on Vietnam was 2.3 percent, 4.2 percent in Korea and 35.8 percent in World War II, according to the Congressional Research Service.

“The war cost has been affordable,” said Gordon Adams, associate director for national security at the Office of Management and Budget during the Clinton administration and now a professor of international relations at American University in Washington. “The worrisome question has been what is the cost of running a high federal deficit? That’s a financing question: how we chose to finance the war.”

The choice to avoid tax increases and pay for the war entirely through budget deficits has compounded the long-term economic impact. The direct cost of the Iraq war to date is about as large as the Obama administration’s 2009 economic stimulus, which the Congressional Budget Office estimated at $825 billion in an Aug. 24 report.

The impact will reverberate beyond the federal budget.

The war has exacted a toll on the broader economy as its consequences rippled through families, businesses and world oil and financial markets. Two separate teams of academics who have sought to determine the economic toll of the conflict estimated it at between $3 trillion and $4 trillion.

Companies, particularly small businesses, have been disrupted by National Guard and Reserve call-ups. Family members of wounded veterans who leave their jobs or reduce work hours to provide care have lost income. The economy has been deprived of the productive contribution of the more than 4,400 service members who have been killed, as well as those who were disabled or left psychologically tormented.

“The war made people worse off during the last decade and it added to the debt load on every American,” said Bilmes, who co-wrote the 2008 book “The Three Trillion Dollar War: The True Cost of the Iraq Conflict” with Joseph Stiglitz. She said they now estimate the price tag at $4 trillion.

Brown University’s “Costs of War” project estimates the overall expense of the wars since the Sept. 11 terrorist attacks at $5.1 trillion, of which $3.2 trillion can be attributed to Iraq, said Catherine Lutz, the project’s co-director and a professor of anthropology at Brown’s Watson Institute for International Studies.

Stiglitz, a Nobel laureate and former chief economist of the World Bank, argues in the book that the war debt encouraged the loose monetary policy that exacerbated the housing bubble and the resulting financial crisis. The debt from the war also limited the Obama administration’s fiscal and political leeway to stimulate the economy during the recession, he said.

Stiglitz said disruptions in Iraqi oil supplies during the war and subsequent strife contributed to the rise in crude prices during the middle of the decade.

The price per barrel of Brent crude, which traded at $26.75 on the eve of the war in March 2003, climbed to a peak of $146.08 on July 3, 2008, according to data compiled by Bloomberg.

While stronger demand from China and India also contributed to higher crude, Stiglitz attributes between $5 and $10 of the increase to the Iraq war. The impact on the oil market reduced economic growth in the U.S. by $800 billion over eight years, he and Bilmes estimate under one scenario they term “realistic.”

Daniel Yergin, chairman of IHS Cambridge Energy Research Associates, said disruption of Iraqi oil supplies was one reason for the run-up in prices. Yet it’s hard to quantify how much the turmoil added to the amount, said Yergin, author of “The Quest: Energy, Security and the Remaking of the Modern World.”

“Iraq was part of a larger pattern of disruptions that also included Nigeria, Venezuela and Hurricanes Katrina and Rita,” Yergin said. “The single most important factor was the surge in demand from China and the emerging markets.”