The Obama administration had just finished a fight with House and Senate Republicans when it entered a battle with a small group of credit-rating analysts based in New York, London and Toronto.

Standard & Poor’s had warned for months that it might downgrade the U.S. credit rating if leaders couldn’t find a way to reduce the growing national debt by $4 trillion over 10 years.

When the deal reached Tuesday fell short of those expectations, the Treasury Department and S&P engaged in a furious set of exchanges that ultimately led to a downgrade Friday night. Since then, the Obama administration and S&P have been engaged in a war of words over the circumstances of the downgrade.

Gene B. Sperling, director of the National Economic Council, said Saturday that S&P’s conduct was “breathtaking,” adding that “it smacked of an institution starting with a conclusion and shaping any arguments to fit it.”

David Beers, the head of S&P’s sovereign rating unit, had a different view. “This agreement will not produce a stabilization of the government’s debt burden on its own, and we don’t have a lot of confidence that another agreement is going to follow this one,” he said.

Friday’s hectic events began at 1:15 p.m. when an S&P analyst called Treasury to say a downgrade would come after the stock market closed, said people familiar with the matter, who spoke on the condition of anonymity to discuss it freely. The analyst sent a draft copy of the downgrade report.

The initial report said the debt in 2021 would reach a worrisome $22.1 trillion, which would be equal to 93 percent of the size of the economy.

Treasury officials reviewed the report and after about 30 minutes found what John Bellows, the acting assistant secretary for economic policy, on Saturday called “a basic math error of significant consequence.”

Treasury argued that S&P calculated spending over the next 10 years in a way that overstated the debt by $2 trillion. Treasury said S&P used the wrong budget metrics to project spending levels.

About 3:15 p.m., Treasury officials called S&P to tell analysts that they had overstated the debt. They heard “stunned silence,” according to some sources familiar with the call. Other sources disputed the characterization.

Two hours later, S&P called Treasury to acknowledge that Treasury’s analysis was correct but told officials that the downgrade would still occur. According to the new calculations, the debt is projected to reach $20.1 trillion, or 85 percent of the size of the economy.

Treasury asked S&P to take more time and wait until Monday to make a final decision.

The officials also argued that S&P analysts did not recognize that Washington was taking steps to tame the national debt despite the political theater of recent months.

But S&P analysts took the opposite view — that all the partisan wrangling made it far less likely that leaders would be able to do what’s necessary to achieve budget savings and that the altered calculation did not change that picture.

Beers reconvened a committee of analysts who vote on ratings decisions to decide whether to proceed with the downgrade. They voted to do so.

At 7:15, S&P called to say it would downgrade and soon thereafter provided a copy of the report to Treasury.

The revised downgrade report more greatly emphasized political analysis — as opposed to economic calculations — compared with the original report, according to a version of the first report reviewed by The Washington Post.

It announced the unprecedented decision at 8:30 p.m.