(Reuters) - The Kansas Legislature on Friday approved a bill that allows faith-based adoption agencies to turn away gay and lesbian couples based on religious beliefs, and the state’s governor said he would sign it.

FILE PHOTO: The mural, Tragic Prelude, which depicts Abolitionist John Brown among Civil War casualties, a prairie fire and a tornado, by John Steuart Curry is seen on the second floor of the Kansas State Capitol building in Topeka, Kansas, U.S., May 12, 2016. REUTERS/Dave Kaup/File Photo

Under the measure, the Kansas Department for Children and Families cannot block any foster or adoption agency, including those that receive public funds, from participating in its programs only because it refuses to adopt or place children with gay people.

Opponents of the bill said they will likely mount a legal challenge.

The U.S. Supreme Court last June reversed an Arkansas Supreme Court ruling and ordered all states to treat same-sex couples the same as heterosexual couples in the issuance of birth certificates. This and other court rulings have made adoption by same-sex couples legal in all 50 states.

The Kansas state Senate passed the measure, SB 284, by a vote of 24-15 early on Friday, just hours after the House of Representatives approved it 63-58. Republicans control both chambers.

“Catholic Charities and other adoption agencies are key to the fabric of our communities,” Republican Governor Jeff Colyer said in a statement. “I look forward to signing this bill because it increases the opportunities for needy children to find loving homes.”

Seven states have similar laws on the books, according to Human Rights Watch, a national gay rights group.

Critics say the legislation will legalize discrimination against same-sex parents. It was opposed by a raft of child welfare organizations as well as the TechNet business group, which includes Dell Inc and Apple Inc.

Defenders of the bill have said that it will increase the number of adoption agencies in Kansas. Organizations can already refuse placements based on religious beliefs and backers say the legislation ensures that adoption agencies are still able to do that.

The Republican-dominated Oklahoma Legislature approved a similar measure on Thursday. Governor Mary Fallin, who is also Republican, has not said whether she will sign it.

Cathryn Oakley, senior counsel for Human Rights Watch, told Reuters by telephone that there was “every chance” of a legal challenge if the Kansas and Oklahoma bills are signed into law.

“These bills are ill-considered and terrible public policy,” she said.