SAN FRANCISCO—California lawmakers passed a bill that bans probation under certain conditions for those convicted of sexual assault. The legislation was passed in response to the backlash over a former Stanford University student who was sentenced to serve six months for his attack.

Brock Turner, a former swimmer at the elite school south of San Francisco, had faced up to 14 years in prison after being found guilty last March of three felony counts of sexual assault of an unconscious woman who had visited the campus for a...