Republicans spent an entire primary cycle searching for Donald J. Trump’s weak spot, to little avail.

But Elizabeth Warren, a first-term Democratic senator from Massachusetts, seems to have come up with an answer — or at least a way to rattle the New York billionaire.

On Friday evening, tensions between Mr. Trump and Ms. Warren spilled into a Twitter war, which spanned four hours and more than a dozen posts and insults — “Goofy Elizabeth Warren,” he called her; a sexist, racist, xenophobic “bully,” she countered — on both sides.

The back-and-forth, which played out in public rat-a-tat-tat bursts, 140 characters at a time, also offered a vivid preview of how the six months until Election Day could unfold, with the popular Ms. Warren emerging as a unifier of the Democratic base and Mr. Trump — so far, at least — still unable to resist small provocations as he tries to become a more disciplined general election candidate.