(CNN) -- Outgoing U.S. Defense Secretary Robert Gates says NATO has become a "two-tiered" alliance poorly equipped to deal with challenges, and with members either unable or unwilling to carry out agreed missions in Afghanistan and Libya.
In his farewell speech Friday to the NATO Council in Brussels, Gates pulled few punches in listing the shortcomings of the alliance.
In particular, he drew a contrast between those members "willing and able to pay the price and bear the burdens of alliance commitments, and those who enjoy the benefits of NATO membership ... but don't want to share the risks and the costs."
"This is no longer a hypothetical worry," he said. "We are there today, and it is unacceptable."
Gates called for urgent action to "avoid the very real possibility of collective military irrelevance."
Ultimately, he said, "nations must be responsible for their fair share of the common defense."
The defense secretary said the problem was in part one of resources.
Pointing to one estimate that European defense spending had declined by nearly 15% in the decade following 9/11, Gates said that only five of the 28 allies now spent the agreed target of 2% of GDP on defense.
Gates said the allied mission in Afghanistan had exposed significant shortcomings of NATO -- in military capabilities and political will.
"Despite more than 2 million troops in uniform -- not counting the U.S. military -- NATO has struggled, at times desperately, to sustain a deployment of 25,000 to 40,000 troops, not just in boots on the ground, but in crucial support assets," he said.
Gates praised governments that had stepped up in Afghanistan.
"Frankly, four years ago I never would have expected the alliance to sustain this operation at this level for this long, much less add significantly more forces in 2010," he said.
That had "decisively changed the momentum on the ground," but NATO must now guard against a "rush to the exits."
"The way ahead in Afghanistan is "in together, out together," Gates said -- with the aim of "inflicting a strategic and ideological defeat on terrorist groups that threaten our homelands."
Gates had harsh words for the conduct of the air campaign against the regime of Moammar Gadhafi in Libya. He said it had become "painfully clear" that shortcomings could "jeopardize the alliance's ability to conduct an integrated, effective and sustained air-sea campaign."
"While every alliance member voted for the Libya mission, less than half have participated at all, and fewer than a third have been willing to participate in the strike mission," he said.
Some did not want to -- others simply were unable to. NATO lacked intelligence, surveillance and reconnaissance assets to do the job. Gates gave one critical example: "NATO air operations center in Italy required a major augmentation of targeting specialists, mainly from the U.S., to do the job. ... We have the spectacle of an air operations center designed to handle more than 300 sorties a day struggling to launch about 150."
Gates praised some NATO members for punching above their weight in the Libya operation.
"Norway and Denmark have provided 12% of allied strike aircraft yet have struck about one-third of the targets," he said. But such examples were the exceptions.
Gates concluded with a candid warning about American willingness to continue bearing a growing part of the NATO burden.
"The blunt reality is that there will be dwindling appetite and patience in the U.S. Congress ... 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," he said.
NATO members must better allocate their resources, follow through on commitments and protect defense budgets from being "further gutted" to avoid "a dismal future," Gates said.