The Boy Scouts national organization said it would defend any local scouting group's "good faith refusal" to admit a scouting leader based upon the group's religious principles.
"This change allows Scouting's members and parents to select local units, chartered by organizations with similar beliefs, that best meet the needs of their families," said a statement from the Scouts' leadership.
The vote represents a remarkably fast turnaround for the Boy Scouts, which only two years ago voted to admit gay young people as scouts but kept the ban on adult gay scout leaders.
Since then, scouting officials have said, rapidly moving legal developments forced a reassessment.
Former Defense Secretary Robert Gates, Scouting's current president, told the organization in May that it must brace for change.
Read MoreCorporate America has more to do on LGBT equality
"We must deal with the world as it is, not as we might wish it to be. The status quo in our movement's membership standards cannot be sustained."
Nearly half the states now have laws prohibiting discrimination on the basis of sexual orientation, and almost 150 local governments have adopted similar provisions.
Gay adults rejected as scout leaders have threatened to sue, and New York's attorney general opened an investigation of the employment policy at the Boy Scouts of America.
"It would be a losing effort," says an internal Boy Scouts of America memo obtained by NBC News, "for the BSA to continue protecting its policy." The memo concludes that "a protracted legal battle ... is unwinnable."
The vote allowing local units to turn away gay leaders was condemned by some former Scout leaders as a timid measure that would allow discrimination to continue.
Peter McGraith, the gay leader of the Transatlantic Council of Boy Scouts of America, called the vote "an expedient move to preempt legal action against BSA national, rather than a genuine attempt to make BSA inclusive."
Read MoreAfter marriage equality, how about the workplace?
John Stemberger, a Florida lawyer who started a breakaway organization called Trail Life USA after the 2013 vote to admit gay Scouts, said by ending the national ban on gay scout leaders, the Boy Scouts "places the churches and religious institutions who sponsor BSA troops at greater legal risk."
Roughly 70 percent of local scouting units are sponsored by religious organizations. But some churches have been openly critical of the ban on gay scout leaders.
Fifteen years ago, the U.S. Supreme Court upheld the Scouts' right to exclude an assistant scoutmaster, James Dale, after he came out as gay. Now the Scouts have concluded they would lose a similar case.
James Dale, himself, agrees.
"Even if you don't exclude a young person, when they become 18 years old they're suddenly not good enough any more? That's definitely the wrong message for the Boy Scouts of America."