The Navy is naming a ship in honor of the late gay rights leader Harvey Milk, who served in the Navy for four years before he began a career in San Francisco city government.

Navy Secretary Ray Mabus said Tuesday that Milk displayed tremendous courage fighting for the rights of the LGBT community. The ship is one of a new fleet of replenishment oilers that will be built in San Diego.

Milk's career as a Navy officer, however, ended with an "other than honorable" discharge, due to allegations of fraternization with enlisted personnel.

Some argue that Milk was forced out of the military because he was gay. A defense official said Tuesday that Milk accepted the other than honorable discharge to avoid possible disciplinary action.

Fraternization with enlisted personnel by an officer is against military regulations — whether they are the same or different genders. The official was not authorized to discuss the matter publicly, and spoke on condition of anonymity.

The ban on gays serving openly in the U.S. military was formally ended in September 2011.

Milk became one of the first openly gay candidates elected to public office. He was serving on the San Francisco Board of Supervisors in 1978 when a former political colleague, Dan White, assassinated him and Mayor George Moscone at City Hall.

Mabus said Milk "offered hope for millions of Americans who were being ostracized and prosecuted just for who they loved."

Speaking in San Francisco during the announcement, Mabus said it was important to honor those like Milk who have fought in a different way, battling — and sometimes dying — for freedom and equality.

Chad Griffin, the president of the advocacy group the Human Rights Campaign, lauded the Navy honor for Milk, calling it "further evidence of the profound progress on LGBTQ equality we continue to make as a nation."

"In his bold and unabashed advocacy, Milk inspired LGBTQ people for generations," Griffin said in a statement.

Five other replenishment oilers will bear the names of civil and human rights leaders: Sojourner Truth, Chief Justice Earl Warren, Robert F. Kennedy, suffragist Lucy Stone and Rep. John Lewis of Georgia.