When his girlfriend said no to sex, Brandon Hampson flew into a rage and beat her, a Nassau County, N.Y., prosecutor on Thursday told a jury in a small Hempstead courtroom.

But the attack was caused by Hampson’s withdrawal from the prescription antidepressant Zoloft, his attorney told jurors.