The Pentagon said Friday that military chaplains may perform same-sex marriages as long as such ceremonies are not prohibited in the states where they reside.

Defense Department guidance said chaplains may participate in the ceremonies on or off military bases. But chaplains are not required to officiate at same-sex weddings if doing so is counter to their religious beliefs, the guidance said.

Regardless of the Pentagon guidance, military chaplains will still need to take cues from their religious order, said Gary Pollitt, spokesman for the Military Chaplains Association.

“Just because the Department of Defense says this can happen, the chaplains perform such rites in keeping with their ecclesiastical authorization,” Pollitt said.

Gay couples may get married in the District and six states — Connecticut, Iowa, Massachusetts, New Hampshire, New York and Vermont. Maryland and several other states recognize same-sex marriages but do not grant marriage licenses to same-sex couples. Forty-one states have either laws or constitutional amendments prohibiting same-sex marriage.

Joe Solomonese, president of the Human Rights Campaign, a gay rights group, said the move “ensures that all military families, including lesbian and gay military families, have equal access to military facilities.”

The Pentagon officially ended its ban on gays in the military last week, and Friday’s guidance is seen as additional, detailed instructions for military chaplains. Similar guidance on how lifting the ban affects other aspects of military life is expected in the coming months.

In May, the Navy issued similar guidance on same-sex marriages, but revoked it amid criticism that it was acting on its own instead of in tandem with other military services.