Under the policy adopted Monday, discrimination based on sexual orientation will also be barred in all Boy Scouts offices and for all paid jobs — a step that could head off looming lawsuits in New York, Colorado and other states that prohibit such discrimination in employment.

One legal threat was immediately averted. In response to the change, the New York State attorney general, Eric T. Schneiderman, announced on Monday that his office was ending its investigation of the Scouts for violating state anti-discrimination laws.

The Boy Scouts’ national executive board, composed of 71 civic, corporate and church leaders, adopted the changes with 79 percent of those who participated in a telephone meeting voting in favor, according to an announcement issued by the Scouts. The announcement did not say how many board members were not present.

The policy change, which was expected, was widely seen as a watershed for an institution that has faced growing turmoil over its stance toward gay people, even as it struggles to halt a long-term decline in members. It was praised by gay-rights organizations as a major if incomplete step toward ending discrimination.

In 2013, facing growing public and internal pressure, the Scouts decided that openly gay youths could participate, but not adults. That approach satisfied no one, forcing the ejection of gay Eagle Scouts when they turned 18 but still causing some conservatives to quit.

Mr. Gates gave an urgent warning in May that because of cascading social and legal changes, the organization had no choice but to end its ban on gay leaders.

In a statement on July 13, the Mormon Church seemed to suggest that it could accept the compromise adopted on Monday. The statement said that any new leadership standard must preserve for its churches “the right to select Scout leaders who adhere to moral and religious principles that are consistent with our doctrines and beliefs.”