Lawmakers in the state Assembly voted 43-34 after a lengthy and emotional debate during which many lawmakers invoked their religious faith in arguing for and against the legislation.