Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

WASHINGTON — Rep. Nancy Pelosi, D-Calif., was elected speaker of the House on Thursday for a second time, as Democrats took control of the lower chamber.

Pelosi — who retook the speaker’s gavel after a formal floor vote that lasted about an hour — reclaimed the House's top leadership post amid a congressional face-off with President Donald Trump over border wall funding that has left parts of the federal government shuttered for the third time in a year.

Pelosi, 78, won with 220 votes, with 12 Democrats voting for someone other than Pelosi and three Democrats voting present. As Pelosi cast a vote for herself, her granddaughter held her hand, jumped excitedly and yelled across the chamber. A number of House Democrats wore blue "Madame Speaker" buttons during the vote.

"Two months ago, the American people spoke, and demanded a new dawn," Pelosi said in remarks in the House chamber after the vote. "They called upon the beauty of our Constitution: our system of checks and balances that protects our democracy, remembering that the legislative branch is Article I: the first branch of government, co-equal to the presidency and judiciary."

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

The California Democrat — who previously served as House speaker from 2007 until 2011, spanning the administrations of Presidents George W. Bush and Barack Obama, and led Democrats under the eight-year Republican majority in the House that followed — secured enough support to win the leadership post late last year, despite a brief insurrection among a small group of Democrats.

The new Democratic Caucus chairman, Rep. Hakeem Jeffries of New York, formally nominated Pelosi on the House floor to rousing applause.

US Speakers of the House by tenure Name Party Time in office Sam T. Rayburn Democratic 17 years, 63 days Thomas P. "Tip" O'Neill Jr. Democratic 10 years, 1 days John W. McCormack Democratic 8 years, 360 days Henry Clay Democratic-Republican 8 years, 136 days J. Dennis Hastert Republican 7 years, 364 days James B. Clark Democratic 7 years, 335 days Joseph G. Cannon Republican 7 years, 116 days James G. Blaine Republican 6 years, 0 days Carl B. Albert Democratic 5 years, 349 days Frederick H. Gillet Republican 5 years, 290 days Andrew Stevenson Jacksonian 5 years, 269 days Thomas S. Foley Democratic 5 years, 212 days John G. Carlisle Democratic 5 years, 92 days Schuyler Colfax Republican 5 years, 88 days Nicholas Longworth Republican 5 years, 87 days Nathaniel Macon No known partisan affilliation 5 years, 87 days John A. Boehner Republican 4 years, 298 days Thomas B. Reed Republican 4 years, 183 days William B. Bankhead Democratic 4 years, 104 days Samuel J. Randall Democratic 4 years, 90 days Joseph W. Martin Jr. Republican 4 years, 1 days Nancy Pelosi Democratic 4 years, 0 days Newt Gingrich Republican 4 years, 0 days Joseph B. Varnum No known partisan affilliation 3 years, 129 days Linn Boyd Democratic 3 years, 93 days David B. Henderson Republican 3 years, 89 days Charles F. Crisp Democratic 3 years, 87 days James K. Polk Jacksonian 3 years, 87 days Jonathan Dayton No known partisan affilliation 3 years, 87 days Paul D. Ryan Republican 3 years, 67 days

Pelosi’s family, including her husband, Paul, and her children were in the gallery, and her nine grandchildren were inside the chamber as well during the vote. Her other guests included singer Tony Bennett, Project Runway host Tim Gunn, Grateful Dead drummer Mickey Hart, and EMILY’S List founder Ellen Malcolm and President Stephanie Schriock, among others.

Her election came as the partial government shutdown stretched into its 13th day, with no deal to end it on the horizon. The House, under the newly elected speaker, planned to vote Thursday on an appropriations package that would end it.

"We will debate and advance good ideas no matter where they come from," Pelosi said. "And in that spirit, Democrats will be offering the Senate Republican appropriations legislation to re-open government later today — to meet the needs of the American people, to protect our borders and to respect our workers."

That vote was scheduled to take place Thursday evening, despite the fact that Senate Majority Leader Mitch McConnell, R-Ky., has said he will not bring up the legislation for a vote in the Senate.

Congressional leaders, including Pelosi, are expected to return to the White House at 11:30 a.m. Friday for another meeting with Trump to discuss the shutdown situation.

Democrats expressed low expectations for any result from the meeting, which they said could be another political stunt.

Also on the new Democratic majority's agenda: oversight. In an exclusive interview with NBC's "Today" ahead of Thursday's vote, Pelosi didn't rule out the prospect of a Trump impeachment.

“We shouldn't be impeaching for a political reason, and we shouldn't avoid impeachment for a political reason," she said.

Asked about the legal opinion that a sitting president cannot be indicted, Pelosi said that it was not settled law. She added that "everything indicates" a "president can be indicted after he is no longer president of the United States."