WASHINGTON — Declaring “great hope and confidence for the future” as well as “deep humility and prayerfulness,” Rep. Nancy Pelosi retook the House speakership Thursday and ushered in a new reality in the nation’s capital.

As Pelosi reprises her historic role as the only woman ever to be House speaker, she becomes a force President Trump will have to reckon with, leading one-third of the lawmaking triumvirate in Washington.

The San Francisco congresswoman takes power amid paralysis in Washington. A shutdown of one-quarter of the government over Trump’s demand for a wall along the U.S.-Mexico border has lasted nearly two weeks with no end in sight.

One of Pelosi’s first orders of business as speaker was bringing a pair of bills to the floor that would reopen government — one to fund most of the shuttered agencies through September, the other to extend funding for the Department of Homeland Security for a month as negotiations over border funding continue. Both measures passed easily late Thursday.

However, that approach is a “nonstarter” in the Senate, according to Senate Majority Leader Mitch McConnell, who says he will not allow a vote on any funding measure unless Trump commits to signing it. The White House declared ahead of the House votes that the president would veto the bills if they reach his desk.

Pelosi’s opening gambit was drawn from a package of bills the Senate passed last month, but because a new term of Congress began Thursday, any legislation has to pass both chambers again to go to Trump. Scheduling the House votes served mostly to increase pressure on Republicans and the president to cave on his demand for $5.6 billion for the border wall to end the shutdown affecting more than 800,000 federal employees and services for millions of Americans.

Pelosi noted the plan in her acceptance speech after winning election as speaker, daring Republicans to reject their own proposal.

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

Trump, for his part, congratulated Pelosi on winning the speakership, doing so in his first appearance ever at the White House media briefing room’s podium. “It’s a very, very great achievement, and hopefully we’re going to work together and we’re going to get lots of things done, like infrastructure and so much more,” Trump said.

Then he invited leaders of the union representing Border Patrol employees to speak to back up his demands for the wall. After several did so, Trump left without taking questions.

In a news conference Thursday evening, Pelosi was steadfast, calling the wall an “immorality” and accusing the president of taking federal employees “hostage.”

The Democrats’ vote to reopen government came after a meeting between the president and congressional leaders on Wednesday ended with no progress. More talks are expected Friday.

One of Pelosi’s close friends, Rep. Anna Eshoo, D-Palo Alto, said Trump will meet his match in the new speaker.

“The country is going to find out who the real negotiator is,” she said.

In her speech accepting the gavel, Pelosi said the nation “is at a historic moment” and laid out Democratic priorities she will pursue as speaker — measures addressing income disparity, climate change, lower health costs and open governance.

She took the oath of office flanked by her grandchildren and other children and grandchildren of members who had witnessed the proceedings on the House floor.

“Working together, we will redeem the promise of the American dream for every family, advancing progress for every community,” Pelosi said. “We must be pioneers of the future.”

She was elected with 220 of the House’s 430 votes, becoming the first person to reclaim the gavel after losing it since Texas Democrat Sam Rayburn in the 1950s. Pelosi was speaker from 2007 until 2011, after Republicans rode Tea Party momentum to retake the House.

Pelosi lost 15 Democratic defectors Thursday, including some who voted “present” — the remnants of a rebellion by a small group of Democrats who had demanded a new face in the House’s most powerful job. Pelosi assured her election when she cut a deal for leadership term limits that would restrict her to a maximum of four more years as speaker.

In a roll call vote at times punctuated by cheers, Democrat after Democrat cast their vote for Pelosi, sometimes with asides.

Rep. Veronica Escobar of Texas voted for “Nancy ‘No Wall’ Pelosi,” and Rep. Steve Cohen of Tennessee voted for “the lady who will truly make America great again.”

Pelosi’s young granddaughter Bella was seated next to Eshoo. When the Palo Alto Democrat cast her vote for Pelosi, Bella clapped emphatically. The girl also stood with her grandmother and jumped up and down while helping Pelosi cast a vote for herself.

In her acceptance speech, Pelosi noted the historic nature of the incoming class, which will bring record numbers of women and unprecedented levels of racial and ethnic diversity to Congress.

“When our new members take the oath, our Congress will be refreshed, and our democracy will be strengthened by the optimism, idealism and patriotism of this transformative freshman class,” Pelosi said.

Tal Kopan is The San Francisco Chronicle’s Washington correspondent. Email: tal.kopan@sfchronicle.com Twitter: @talkopan