“The odds of repeating another Afghanistan or Iraq  invading, pacifying, and administering a large third-world country  may be low,” Mr. Gates said, but the Army and the rest of the government must focus on capabilities that can “prevent festering problems from growing into full-blown crises which require costly  and controversial  large-scale American military intervention.”

Mr. Gates was brought into the Bush cabinet in late 2006 to repair the war effort in Iraq that was begun under his predecessor, Donald H. Rumsfeld, and then was kept in office by President Obama. He did not directly criticize the Bush administration’s decisions to go to war. Even so, his never-again formulation was unusually pointed, especially at a time of upheaval across the Arab world and beyond. Mr. Gates has said that he would leave office this year, and the speech at West Point could be heard as his farewell to the Army.

A decade of constant conflict has trained a junior officer corps with exceptional leadership skills, he told the cadets, but the Army may find it difficult in the future to find inspiring work to retain its rising commanders as it fights for the money to keep large, heavy combat units in the field.

“Men and women in the prime of their professional lives, who may have been responsible for the lives of scores or hundreds of troops, or millions of dollars in assistance, or engaging or reconciling warring tribes, may find themselves in a cube all day re-formatting PowerPoint slides, preparing quarterly training briefs, or assigned an ever-expanding array of clerical duties,” Mr. Gates said. “The consequences of this terrify me.”

He said Iraq and Afghanistan had become known as “the captains’ wars” because “officers of lower and lower rank were put in the position of making decisions of higher and higher degrees of consequence and complexity.”