BRUSSELS — Defense Secretary Robert M. Gates sharply criticized NATO nations on Friday for what he said were shortages of military spending and political will, warning of “a dim if not dismal future” and “irrelevance” for the alliance unless more member nations contributed weapons, money and personnel.

In his final policy speech before he steps down, Mr. Gates issued a dire and unusually direct warning that the United States, the traditional leader and patron of the alliance, was exhausted by a decade of war and its own mounting budget deficits and simply might not see NATO as worth supporting any longer.

“The blunt reality,” Mr. Gates said, “is that there will be dwindling appetite and patience in the U.S. Congress — and in the American body politic writ large — to expend increasingly precious funds on behalf of nations that are apparently unwilling to devote the necessary resources or make the necessary changes to be serious and capable partners in their own defense.”

The White House made clear on Friday that in the tough tone of his remarks, Mr. Gates was speaking for the Pentagon, not necessarily for the administration, and that he appeared to be expressing his own frustrations after years of asking NATO to do more. But a White House official did say that Mr. Gates’s speech raised “legitimate concerns” about whether NATO was providing enough resources for the war and that the Obama administration fully expected the alliance to meet its challenges.