Gates called the graduation "a joyous day in a difficult time."
"Today, we ask you to make the extraordinary expected," Gates said during a sunny ceremony at the Navy-Marine Corps Stadium in Annapolis.
Gates also commended the new officers, whose class motto is "liberty through sacrifice," for choosing the academy and military life instead of attending other schools.
Gates told the newly minted officers to use the leadership skills they have been taught and to understand the importance of the press, even when they read or hear unfavorable reports about the military.
"The press is not the enemy and to treat it as such is self-defeating," Gates said, citing recent reports about poor conditions at Walter Reed Army Medical Center as an example of the value of the press.
An estimated 27,000 people attended the academy's 157th traditional ceremony.
There are 1,028 graduates this year, including 862 men and 166 women.