Retired Lt. Cmdr. Wesley A. Brown, a descendant of Virginia slaves who endured racial taunts and merciless hazing to become the first black midshipman to graduate from the U.S. Naval Academy, in 1949, died May 22 at the Springhouse assisted living center in Silver Spring. He was 85.

He had metastatic cancer, said his wife, Crystal Brown.

Cmdr. Brown, a Dunbar High School graduate who grew up in a rowhouse on Q Street near Logan Circle, served 20 years in the Navy as a civil engineer. He helped design a water treatment facility in Cuba, roads across Liberia, an air station in the Philippines and a nuclear plant in Antarctica.

His lasting mark was his determination to be the first black graduate of the Naval Academy in Annapolis since its founding in 1845. Five other black midshipmen had come before him; none had graduated. Most were forced to resign from the academy because of a hostile racial climate.

According to the 2005 book “Breaking the Color Barrier” by naval historian Robert J. Schneller Jr., Cmdr. Brown was the victim of a hazing campaign orchestrated by Southern upperclassmen who sought his dismissal.

Upon enrolling in 1945, he endured racial epithets and ostracism from his classmates. A group of upperclassmen gave him so many demerits during his first term — mostly for fabricated infractions or petty offenses — that he was threatened with expulsion.

“I get asked that question often, ‘Did you ever think about quitting?’ ” Cmdr. Brown once said in an interview. “And I say, ‘Every single day.’ ”

In October 1945, a front-page story in The Washington Post announced that Rep. Adam Clayton Powell Jr. (D-N.Y.) had written a letter to then-Navy Secretary James Forrestal stating that there was a “concerted effort” at the Academy to oust Cmdr. Brown.

Powell, who had appointed Cmdr. Brown to the Naval Academy, received a reply from Forrestal indicating that he investigated the case and had found no problems.

In a memoir, Powell later wrote that he had trumped up his charges to protect Cmdr. Brown from mistreatment.

“When I came to the academy I learned that there were all kinds of prejudices — against Jews, Catholics, even the Irish,” Cmdr. Brown said in a 2005 with the Baltimore Sun. “And I looked around and thought that these prejudices were instilled in them by their families, and they could not be blamed for feeling the way they did.”

Eventually, sympathetic upperclassmen came to his aide and helped guide Cmdr. Brown’s development as a future naval officer. Among them was his track teammate, a Georgia peanut farmer’s son named Jimmy Carter.

On June 3, 1949, Cmdr. Brown was commissioned as a Navy officer, graduating 370th out of his class of nearly 800. Many newspapers covered his graduation as a landmark achievement in military history. Cmdr. Brown saw it differently.

“I feel it is unfortunate the American people have not matured enough to accept and individual on the basis of his ability and not regard a person as an oddity because of his color,” Cmdr. Brown told the New York Times in 1949. “My class standing shows that around here I am an average ‘Joe.’ ”

Wesley Anthony Brown was born April 3, 1927, in Baltimore and grew up in Washington, where his father delivered groceries and his mother worked in a dry cleaning shop. In his book, Schneller wrote that Cmdr. Brown’s great-grandparents had been born into slavery.

He was a 1944 Dunbar High School graduate and served in the Army reserves as a teenager.

Cmdr. Brown retired from the Navy in 1969. Since him, more than 1,700 black students have graduated from the Naval Academy, including Navy admirals, Marine Corps generals, basketball star David Robinson and NASA administrator Charles F. Bolden.

From 1976 to 1988, he was the facilities planner for Howard University.

His first marriage, to the former Jean Alston, ended in divorce. Survivors include his wife of 49 years, Crystal Malone Brown of Silver Spring; four children from his first marriage, Wiletta West of Philadelphia, Carol Jackson of Long Beach, Calif., Wesley A. Brown Jr. of Fall River, Mass., and Gary Brown of Coral Gables, Fla.; seven grandchildren; and two great-grandchildren.

In 2008, the Naval Academy dedicated its $50 million indoor track facility in Cmdr. Brown’s honor.

At his home, Cmdr. Brown kept a prized letter from Carter, his former track teammate.

“I ran with you,” the 39th president wrote to Cmdr. Brown, but “you were better.”