JEWEL SAMAD / AFP / Getty

During my 40 years as a Marine officer, including nearly four years as commandant of the Marine Corps, I came to believe that one of the military’s most important missions is to lead the fight against hate, inequality, and injustice, both at home and overseas. The factors that divide Americans today pose a greater threat to the country than any foreign adversary does. For this reason, the Pentagon must respond forcefully to alarming evidence that white-supremacist groups and other extremist organizations might be seeping into the armed forces and targeting uniformed service members and veterans for recruitment, coveting their training in weapons and tactical knowledge.

In a survey taken earlier this year, Military Times found that one in three active-duty service members says “they have personally witnessed examples of white nationalism or ideological-driven racism within the ranks in recent months”—a significant increase from surveys conducted the previous year.

One of the poll respondents wrote, “The majority of my co-workers were absolutely outstanding regarding race and work-relations and I credit military service for that. Nevertheless, somehow more racists are slipping through the cracks into the military.” The problem is not solely an American one. Last year, Germany was forced to dismantle an elite special-forces unit after it was compromised by the infiltration of neo-Nazis. This infiltration endangered not just Germany’s military readiness but NATO’s. The United States armed services and their counterparts in allied countries must close off all means by which white supremacists, anarchists, or fascists enter our national institutions and social mainstreams. The members of the U.S. armed forces have an obligation to defend our nation from all enemies, “foreign and domestic”—including those who would divide us from within.

Over the course of my career, I have been privileged to serve alongside men and women who believed in America, for all its shortcomings. In October 1967, six months after being commissioned a Marine second lieutenant, I joined a deployed infantry battalion along the demilitarized zone separating North and South Vietnam. My platoon’s first real combat engagement occurred soon after. One day in late December 1967, we came upon a large North Vietnamese unit preparing to attack the enormous military complex in the city of Da Nang as part of the 1968 Tet Offensive.

The ensuing firefight lasted until dawn the next morning. Among our casualties that day was Private First Class Robert Wilson. Robert was Black. I am white. We both came from Virginia; back in our home state, and around the country, the battle for civil rights was still raging.

Like the many other Black service members who lost their life in Vietnam or in other U.S. military campaigns since 1776, Wilson died fighting for ideals of equality and justice that had not yet been fulfilled at home. He had taken an oath to “support and defend the Constitution,” hoping that our country would, one day, fulfill its sacred promises for all. In my platoon, Wilson was enormously popular. He was always optimistic, even joyful, in everything he did and was asked to do. The grief that the platoon felt upon his death reminded us that we were all brothers in arms.

Wilson’s memory was with me when Barack Obama—whom I served as national security adviser—was sworn in as commander in chief. But Wilson was also on my mind more recently, when images of George Floyd, unable to breathe under the knee of a police officer sworn to uphold his rights, ignited nationwide protests over racial injustice.

Today, our nation desperately needs institutions that, rather than reinforce divisions within our society, bind Americans together. The American military, though not perfect, is one such institution.

Despite being burdened by its own troubled history with discrimination and racial injustice—and by the efforts of white supremacists to recruit within its ranks—the U.S. military has often served as a vanguard for social change and progress toward greater equality. It can, and must, help lead the country through this moment of national reckoning on racial issues, and as a very large institution that enjoys the admiration of the overwhelming majority of our citizenry, it is uniquely qualified to do so.

In 1948, President Harry Truman ordered an end to segregation in the U.S. armed forces well before the passage of landmark civil-rights measures in the ’60s. In 1957, President Dwight Eisenhower deployed the 101st Airborne Division to enforce the desegregation of Central High School in Little Rock, Arkansas. In 1973, as the United States military transitioned from the draft to an all-volunteer force, the Defense Department knew that no segment of society could be overlooked if it was to successfully generate the manpower and cohesion necessary to meet the country’s missions. The defense of democracy required the creation of a true meritocracy. The department and the services recruited widely and adopted strict regulations against discrimination, bolstered by programs and initiatives to eliminate it whenever discovered. Beginning in 1980, each branch of the armed services required every promotion board to have at least one minority member responsible for looking out for the interests of qualified minority candidates—a safeguard that most civilian employers still do not have.

Today, we celebrate the recent appointment of General Charles Q. Brown, who is Black, to serve as chief of staff of the Air Force. In 1999, I had the honor of selecting Sergeant Major Alford McMichael to become the sergeant major of the Marine Corps. He was the first Black person to hold the position. In 2003, he was appointed as the first sergeant major of NATO’s operational forces in Europe. Such appointments, taken individually, do not guarantee adequate representation. Military leadership is still overwhelmingly white and male, but change is inexorably coming to all the services. The commitment to becoming a meritocracy enabled the military to identify, cultivate, and elevate figures such as General Colin Powell, who entered the service when, in many parts of the country, white and Black service members drank from separate water fountains.

Helping the country rectify racial injustice and respond to demands for change, at least in part, within the military has been a long-standing policy. Achieving that imperative—like all institutional change—requires committed leadership. Establishing recruiting practices that bar those who don’t reflect the nation’s values and who would disrupt the services’ good order and discipline should be a top priority, as should identifying those who have infiltrated the ranks, to get them out of uniform as quickly as possible. Social media can help recruiters and commanders more quickly identify bigots and extremists. Hate groups who seek to recruit military personnel or veterans into the sickness of bigotry must meet with complete failure and rejection.

An important question for society is why and how racist ideology is still able to infiltrate national institutions and persist, even as our schools and religious institutions teach us to erase it from our hearts, and our nation’s principles and laws give it no sanction.

The military must study what might attract hate groups and extremists to join or recruit from its active-duty ranks and its veterans. A desire to gain experience with firearms and military tactics is one possible explanation. The large majority of Americans join the all-volunteer force because they are attracted not to its tactics and means, but to its ends—service to the country and defense of values that include equality. One key reason the military is more widely admired today than in the 1960s and ’70s is that Americans correctly see its devotion to meritocracy and teamwork, and they know that it has long been a leader in civil rights and race relations. Simply put, the military today returns better American citizens to our society than it takes in.

In the military, as in society, weeding out racism must be accompanied by continuously striving to improve equal opportunity and inclusion not only as a matter of justice, but because valuing different perspectives will improve the military and enhance its ability to accomplish its goals. As a New York Times story pointed out earlier this year, “Some 43 percent of the 1.3 million men and women on active duty in the United States military are people of color.” Ensuring that military leadership looks more like its troops requires a well-conceived campaign of professional development and career advancement.

The progress continues. Secretary of Defense Mark Esper recently established boards to identify immediate and medium-term steps to promote diversity and inclusion within the department. The inspector general of the Air Force has also announced a comprehensive review of racial inequality in the service. Other services would do well to follow suit.

When the military succeeds in promoting meritocracy and banishing prejudice, the benefits accrue to American society as a whole. The military’s experience in this domain can also help law enforcement reform where needed. Most police officers—many of whom served in the military—are selfless public servants striving to do right every day of their career. But that does not mitigate the need to act aggressively when faulty leadership, poisoned organizational culture, and the presence of bad actors result in egregious civil-rights violations. Police departments and many other organizations can learn from U.S. armed forces, which cultivate the ability of service members of all ranks—and all backgrounds—to think on their feet and make well-reasoned decisions under pressure.

In the end, justice, equal protection under the law, and the preservation of liberty and human rights are what make a nation worth defending. America’s purpose and moral authority are gravely undermined when civic institutions created to preserve and protect these ideals fail to do so. The U.S. military, like American society, is still a work in progress. Only by constantly striving to defend equality and justice can we honor the sacrifice of service members such as Robert Wilson. And only by living up to our country’s grand ideals and values can we all rightfully call ourselves Americans.

We want to hear what you think about this article. Submit a letter to the editor or write to letters@theatlantic.com.