LONDON — After months of pressure from the United States, Britain committed on Wednesday to meeting NATO’s military spending target for the rest of the decade, as the government outlined broader plans to smooth the path toward healthy public finances.

The announcement follows protracted discussions within the British government, and criticism from outside it, that Britain is retreating from its global role at a time of growing security challenges.

Although Britain now exceeds NATO’s target figure for military expenditure of 2 percent of gross domestic product, experts had predicted that it would fall below the threshold because of government spending cuts. But in a budget statement on Wednesday, George Osborne, the chancellor of the Exchequer, made a surprise promise to hit the NATO figure “not just this year, but every year of this decade.”

“We will ensure that this commitment is properly measured,” Mr. Osborne told lawmakers, “because we know that while those commitments don’t come cheap, the alternatives are far more costly.”