Robert M. Gates gave his final commencement speech as defense secretary Friday. Speaking to the graduates at the U.S. Naval Academy in Annapolis, Gates, who retires next month, shared his observations about leadership, which he called “a rare and precious commodity.” His thinking on the subject, he said, was honed during his decades-long career, which includes serving under eight presidents.

On Memorial Day, we offer an excerpt:

While many people witness history, those who step forward to serve in a time of crisis have a place in history. As of today, you join the long line of patriots in a noble calling. By your service you will have a chance to leave your mark on history. . . .

As you start your careers as leaders today, I would like to offer some brief thoughts on those qualities. For starters, great leaders must have vision — the ability to get your eyes off your shoelaces at every level of rank and responsibility and see beyond the day-to-day tasks and problems. To be able to look beyond tomorrow and discern a world of possibilities and potential. How do you take any outfit to a higher level of excellence? You must see what others do not or cannot and then be prepared to act on your vision.

An additional quality necessary for leadership is deep conviction. True leadership is a fire in the mind that transforms all who feel its warmth, that transfixes all who see its shining light in the eyes of a man or woman. It is a strength of purpose and belief in a cause that reaches out to others, touches their hearts and makes them eager to follow.

Self-confidence is still another quality of leadership. Not the chest-thumping, strutting egotism we see and read about all the time. Rather, it is the quiet self-assurance that allows a leader to give others both real responsibility and real credit for success. The ability to stand in the shadow and let others receive attention and accolades. A leader is able to make decisions but then delegate and trust others to make things happen. This doesn’t mean turning your back after making a decision and hoping for the best. It does mean trusting in people at the same time you hold them accountable. The bottom line: A self-confident leader doesn’t cast such a large shadow that no one else can grow.

A further quality of leadership is courage: not just the physical courage of the seas, of the skies and of the trenches, but moral courage. The courage to chart a new course, the courage to do what is right and not just what is popular, the courage to stand alone, the courage to act, the courage as a military officer to “speak truth to power.”

In most academic curricula today, and in most business, government and military training programs, there is great emphasis on team-building, on working together, on building consensus, on group dynamics. You have learned a lot about that. But, for everyone who would become a leader, the time will inevitably come when you must stand alone. When alone you must say, “This is wrong” or “I disagree with all of you and, because I have the responsibility, this is what we will do.” Don’t kid yourself — that takes real courage.

Another essential quality of leadership is integrity. Without this, real leadership is not possible. Nowadays, it seems like integrity — or honor or character — is kind of quaint, a curious, old-fashioned notion. We read of too many successful and intelligent people in and out of government who succumb to the easy wrong rather than the hard right — whether from inattention or a sense of entitlement, the notion that rules are not for them. But for a real leader, personal virtues — self-reliance, self-control, honor, truthfulness, morality — are absolute. These are the building blocks of character, of integrity — and only on that foundation can real leadership be built.

A final quality of real leadership, I believe, is simply common decency: treating those around you — and, above all, your subordinates — with fairness and respect. An acid test of leadership is how you treat those you outrank, or as President Truman once said, “how you treat those who can’t talk back.” . . .

Above all, remember that the true measure of leadership is not how you react in times of peace or times without peril. The true measure of leadership is how you react when the wind leaves your sails, when the tide turns against you.