WASHINGTON — Speaker Nancy Pelosi and President Trump were discussing gun violence over the telephone Tuesday morning when the president abruptly changed the topic to an intelligence community whistle-blower complaint that had Democrats talking about impeachment.

Ms. Pelosi stopped him short.

“Mr. President,” she declared, according to a person familiar with the conversation, “you have come into my wheelhouse.”

The remark was a reference to Ms. Pelosi’s quarter-century of experience with intelligence matters in Congress, an aspect of her biography that played a central role in her decision on Tuesday to open a formal impeachment inquiry into Mr. Trump.

The move is her most consequential act as speaker, and one that could shape the future of the Trump presidency, the 2020 election and the nation. It is the latest chapter in her fraught relationship with the president, and a stark turnabout for Ms. Pelosi, who until days ago had been deeply resistant to impeaching Mr. Trump despite the deep disgust she has expressed for him and his conduct.