WASHINGTON — Speaker Nancy Pelosi lashed out in anger on Thursday at a reporter who asked whether she hated President Trump, prompting Mr. Trump to accuse her of having “a nervous fit.”

The flash of anger from Ms. Pelosi — “Don’t mess with me,” she told the reporter — came as she was leaving a news conference in which she had just finished discussing her decision to move forward with articles of impeachment against Mr. Trump.

“Do you hate the president?” James Rosen, a reporter for a conservative television network, Sinclair Broadcast Group, asked loudly as Ms. Pelosi made her way offstage in a television studio near the Capitol.

Ms. Pelosi whipped around to face Mr. Rosen, wagging her finger at him and saying, “Don’t accuse me,” as he explained that he was asking her to respond to Republicans’ claims that Democrats were pursuing Mr. Trump’s impeachment out of personal animus against him.