The House has elected Nancy Pelosi as its speaker as Democrats take command of the chamber for the new Congress.

The near party-line majority vote makes her the country's most powerful Democrat as the party begins two more years of confronting President Donald Trump. Except now, Pelosi's Democrats will be able to set the House's legislative agenda and conduct investigations of the Trump administration that Republicans shunned when they held the majority.

Thursday's vote restores Pelosi to the post the Californian held from 2007 until 2011. She's the only woman to ever hold the chamber's top job.

Pelosi, of California, reclaimed the job after Democrats gained 40 seats in the November elections, their biggest pickup in four decades.

In her first remarks after winning election as speaker, Pelosi says the House must fight for the middle class in way that's fair and financially sound while also protecting Medicare, Medicaid and Social Security.

She says the House must also address climate change, which she calls "the existential threat of our time." The California Democrat says the American people understand the urgency of addressing global warming and "the Congress must join them."

Pelosi also says that Democrats will also pursue legislation to lower health care and prescription drug costs and work to rebuild the country with "green and modern infrastructure from sea to shining sea."

"We must be champions of the middle class and all those who aspire to it. Because the middle class is the back bone of our democracy. It has been since the birth of our democracy." 

Earlier, new senators mingled with their colleagues and a few predecessors as they walked up to the dais in groups of four to be sworn in by Vice President Mike Pence on Thursday.

The only new senator not to be sworn in was Republican Sen.-elect Rick Scott, who received permission to complete his term as Florida's governor and will be sworn in Jan. 8.

It's also the first new Congress to convene during a partial government shutdown, now in its 13th day over Trump's demands for money for a southern border wall.

U.S. Senator Catherine Cortez Masto (D-Nev.) issued the following statement welcoming Senator Jacky Rosen (D-Nev.) and congratulating the Senator on her swearing in.

“In the span of two years Nevada has made history, electing it’s first and second female Senators, a majority female legislature and Nevada Supreme Court. I’m thrilled to welcome Jacky to the Senate and congratulate her on her first day as the newest Senator from the Silver State. In the House, Jacky fought hard to protect health care for thousands of Nevadans, restore internet privacy protections, champion STEM education and oppose efforts to revive Yucca Mountain. I’m looking forward to working alongside her as she brings the same tenacity to the Senate and as we continue to fight for Nevada’s priorities.”

Senator Rosen replaces former Senator Dean Heller. 

“I am deeply humbled by the opportunity to serve Nevada in the Senate,” said Senator Jacky Rosen.  “I’m ready to get to work and find common sense solutions for Nevada and the country. There is a lot of work ahead of us, and that starts with ending this senseless and avoidable shutdown and defending protections for Americans with pre-existing conditions. I believe in agreeing where we can and fighting where we must. That’s why I’ll always do what’s right for Nevada.” 

(The Associated Press contributed to this report.)