Former Representative Liz Cheney, the once high-ranking Republican from Wyoming who torpedoed her political career by breaking forcefully with former President Donald J. Trump, said on Wednesday she would be voting for Vice President Kamala Harris in November.

During an event at Duke University, Ms. Cheney told students that it was not enough for her to simply oppose the former president, if she intended to do whatever was necessary to prevent Mr. Trump from winning the White House again, as she has long said she would.

“I don’t believe we have the luxury of writing in candidates’ names, particularly in swing states,” Ms. Cheney said, speaking to students in the hotly contested state of North Carolina. “As a conservative, as someone who believes in and cares about the Constitution, I have thought deeply about this and because of the danger that Donald Trump poses, not only am I not voting for Donald Trump, but I will be voting for Kamala Harris.”

The room erupted in cheers after she made her unexpected announcement.

The decision by Ms. Cheney, whose endorsement Ms. Harris’s campaign had been courting for weeks, to shift from condemning Mr. Trump to backing the Democratic presidential nominee was a striking one even from a leader who has established herself as one of the most vocally anti-Trump Republicans in the country.

In an interview with Fox News in August of 2020, after President Biden selected Ms. Harris as his running mate, Ms. Cheney described his pick as someone “whose voting record in the Senate is to the left of Bernie Sanders and Elizabeth Warren.” She added: “It’s very clear, she is a radical liberal.”

Ms. Cheney, a daughter of former Vice President Dick Cheney, is a member of a private and deeply conservative political family. She is pro-gun and anti-abortion and favors a stronger national defense.