In a mostly party-line vote, the House of Representatives on Tuesday approved a measure that prohibits the Department of Defense from allowing nonbelievers to serve as chaplains.

All but six House Republicans voted for the measure, which was offered as an amendment to the annual defense spending bill. Rep. John Fleming (R-LA), who offered the amendment, said it was necessary because the Pentagon was considering appointing an atheist chaplain to represent nonbelievers in the military.

"Since the formation of the chaplaincy in 1775, chaplains have been affiliated with a faith and spirituality," Fleming said on the House floor. "By definition, chaplains minister to the spiritual needs of our men and women in the Armed Services, a vital function that an individual without an inclination towards spirituality would not be able to perform."

Only 26 Democrats voted in favor of the amendment.

Rep. Jared Polis (D-CO) and Rep. Robert Andrews (D-NJ) had offered amendments that would have permitted nonbelievers to serve as chaplains, but the amendments were defeated. They said it was unfair that non-religious service members could only confide in a mental health professional, while religious service members could seek out a chaplain who represented their faith.

"Chaplains for nontheistic military service members are absolutely crucial for so many men and women who are serving our country," Edwina Rogers, executive director of the Secular Coalition for America, said in a statement on Wednesday. "Religious chaplains are ill equipped to handle the problems of nontheistic service members and unfortunately, seeking psychiatric help can stigmatize a service member for the rest of their career."