ANNAPOLIS, Md. — With a growing sexual assault epidemic staining the military, President Barack Obama urged U.S. Naval Academy graduates Friday to remember their honor depends on what they do when nobody is looking and said the crime has “no place in the greatest military on earth.”

The commander in chief congratulated the 1,047 midshipmen graduating at the Navy-Marine Corps Memorial Stadium, telling the 841 men and 206 women that they have proven themselves morally by meeting rigorous standards at the academy. But their commencement celebration came in the midst of reports of widespread sexual assault throughout the military, and Obama ended his 20-minute address by recognizing “how the misconduct of some can have effects that ripple far and wide.”

“Those who commit sexual assault are not only committing a crime, they threaten the trust and discipline that makes our military strong,” Obama said. “That’s why we have to be determined to stop these crimes, because they’ve got no place in the greatest military on Earth.”

His pointed comments were aimed at rooting out the problem at a time when Republicans have been criticizing Obama for not responding forcefully enough to controversies including last year’s deadly attack in Libya and political targeting at the IRS.

But Obama was quick to express outrage over the reports of sexual assault, saying he has no tolerance for it. He summoned military leaders to the White House last week and instructed them to lead a process to root out the problem.

The Pentagon released a report earlier this month estimating that as many as 26,000 military members may have been sexually assaulted last year and that thousands of victims are unwilling to come forward despite new oversight and assistance programs. That figure is an increase over the 19,000 estimated assaults in 2011.

Several recent arrests have added to the military’s embarrassment. A soldier at the U.S. Military Academy at West Point was charged with secretly photographing women, including in a bathroom. The Air Force officer who led the service’s Sexual Assault Prevention and Response unit was arrested on charges of groping a woman. And the manager of the Army’s sexual assault response program at Fort Campbell, Ky., was relieved of his post after his arrest in a domestic dispute with his ex-wife.

The applause that had accompanied earlier portions of Obama’s Naval Academy speech, as he mentioned the Navy Seal’s killing of Osama bin Laden and called for the building of a powerful 300-ship fleet, fell to silence as he turned to the sexual assault scandal. Midshipmen and spectators watching under cool gray skies as a light rain fell listened silently as he repeated the refrain: “We need your honor.”

Obama urged the graduates to use the leadership skills and values learned at the academy to help prevent behavior in the battlefield that can damage the image of the U.S. overseas.

“We need your honor, that inner compass that guides you, not when the path is easy and obvious, but it’s hard and uncertain, that tells you the difference between that which is right and that which is wrong,” Obama said. “Perhaps it will be the moment when you think nobody’s watching. But never forget that honor, like character, is what you do when nobody’s looking.”