Rep. Nancy Pelosi reclaimed the House speakership on Thursday in a historic comeback for the first female speaker, securing her place as the most powerful woman in American politics and the face of the Democratic opposition to the polarizing presidency of Donald Trump.

Pelosi immediately presented herself as a leader whose powers are on a par with Trump’s after two years in which he has largely had his way with Republican leaders, pointedly describing Congress as “coequal to the president and judiciary,” as she promised to deliver on a Democratic vision on health care, immigration and climate change.

Within hours, Pelosi made good on that pledge, as Democrats voted for legislation to reopen the government, shuttered for two weeks in a standoff with Trump over his demands for funds for a U.S.-Mexico border wall.

“Two months ago, the American people spoke, and demanded a new dawn,” she said during an address to the House soon after securing a 220-to-192 vote affirming her speakership. “They called upon the beauty of our Constitution: our system of checks and balances that protects our democracy.”

The tensions with Trump were ever-present. Though Pelosi (D-Calif.) spoke of bipartisan cooperation with Republicans, invoking the late GOP presidents George H.W. Bush and Ronald Reagan, she did not mention the current president by name.

Trump, for his part, congratulated the speaker during a surprise appearance in the White House briefing room. But he used the event, an appearance with border security guards, as a chance to signal that he was digging in on his position on funding the wall — a stand that Pelosi has repeatedly rejected.

Amid the impasse, Pelosi and her fellow Democrats have also signaled in recent weeks that they intend to move aggressively to use their newfound powers to investigate Trump and his administration from multiple angles. She even suggested in a television interview that he was not immune to indictment.

Congressional leaders, including Pelosi, will meet with Trump on Friday — the 14th day of the shutdown, which some Republicans signaled could last months.

On a day of pomp and ceremony, the realities of the spending crisis tempered — if only slightly — the jubilation of the freshman class at being sworn in as lawmakers after months of relentless campaigning and orientation.

“It’s an exciting time, but it’s also a time in which — at least members of the freshman class I’ve spoken to — are eager to get to work,” said Rep. Joseph Neguse (D-Colo.), the son of refugees from Eritrea. “No time better than the present to reopen the government and get back to the people’s business.”

Signs of change were on display throughout the day. Holy books of the Muslim, Hindu and Buddhist faiths sat alongside Bibles set to be used by incoming members taking their ceremonial oaths of office. Rep. Jim Langevin (D-R.I.), a quadriplegic who uses a wheelchair, presided over the first floor business of the new House session — including new rules that, among other things, allowed religious headwear on the House floor for the first time and officially banned discrimination on the basis of sexual orientation or gender identity.

On Thursday, 102 women took the oath of office in the House and 25 in the Senate — nearly a quarter of the overall voting membership of Congress. Several states have sent African American women to the House for the first time, and Texas, 40 percent Latino, sent its first Hispanic women. Ten Democrats openly identify as gay, lesbian or bisexual, a new high. In the Senate, six states are now represented only by women, a first.

Pelosi’s election was itself momentous — not only for the historic import of returning the speakership to the first woman ever to hold the post, but also for the feat of political resilience. Not in 64 years has a former speaker regained a gavel, and never has a former speaker done it after eight years in the minority.

“She’s like Toscanini conducting a jazz band,” said former congressman Steve Israel (D-N.Y.), who returned to the Capitol to greet old friends and savor the return to power. “Only she can pull it off.”

Pelosi’s election followed a tense period after the Nov. 6 midterms during which rebellious Democrats pressed for her to step aside in favor of a younger leader. Instead, she battled for weeks to pick off vote after vote, finally securing her victory in mid-December by agreeing to serve no more than four more years as speaker.

In the end, 15 Democrats cast votes for an alternative or for no one at all, but Pelosi won 220 votes — four more than necessary.

Republicans, meanwhile, made peace with their dismal new reality as the minority in a body where the majority reigns supreme. Leadership offices have been downsized, lofty titles have evaporated, and raw power has given way to ineffective protests.

In their first act in the minority, House Republicans moved to force a vote on tax cuts — which would have interrupted Democrats’ plans to hold votes on funding federal agencies, as well as coming bills on health care, ethics and other issues. Democrats immediately voted to kill the proposal on a party-line vote.

“You don’t get your way on anything,” said Rep. Randy Weber (R-Tex.), who, like three-quarters of incumbent House Republicans, has served only with robust GOP majorities. “We’re going to deal with it like anything else — take your lumps as they come, work like hell getting your message out to the American people and getting back the majority.”

Besides the tax-cut gambit, Republicans threw a few barbs across the aisle. Rep. Liz Cheney (R-Wyo.), one of only 13 women in House GOP ranks, nominated Rep. Kevin McCarthy (R-Calif.) by praising him as a leader who would “stand against the fraud of socialism” — a reference to the hard-left lawmakers who have pushed Democratic leaders and threatened to oppose them if they resist.

When the breakout star of that group, Rep. Alexandria Ocasio-Cortez (D-N.Y.), cast her vote for Pelosi, several Republicans could be heard groaning. “Sorry,” Ocasio-Cortez mouthed back at them with a smile.

Pelosi will face challenges in balancing the liberal wing and moderates from Trump-won districts. She moved quickly to assuage the liberals’ concerns with the creation of a special committee on climate change and hearings on a potential Medicare-for-all health-care plan but still faced some grumbles this week.

In the Senate, meanwhile, Republicans solidified a narrow majority while Majority Leader Mitch McConnell publicly disclaimed responsibility for breaking the spending impasse. Hovering over it all was Trump, who showed no sign of adapting to the new political environment.

McConnell (Ky.) said he has stepped back in the spending talks because “the solution to this is a deal between the president and Nancy and Chuck, because we need some of Chuck’s votes and obviously we need Nancy’s support,” referring to Pelosi and Senate Minority Leader Charles E. Schumer (D-N.Y.).

Citing Trump’s opposition, Senate Republican leaders do not plan to vote on the House Democrats’ spending bills, even though many Republican senators personally support the legislation, which is based on bipartisan compromises reached in the Senate.

“If we don’t get over this, if this goes on for months and months — it could, hope not — then that might be a preview of coming attractions,” said Sen. Richard C. Shelby (R-Ala.), chairman of the Senate Appropriations Committee.

Meanwhile, the most famous freshman senator, Republican Mitt Romney of Utah, rubbed some of his new colleagues the wrong way with an op-ed in The Washington Post this week arguing that the president had “not risen to the mantle of the office.”

“I think it was just a clumsy way to get started, you know, as a new senator. I disagree with the timing for sure, and a lot of the content, as well,” said Sen. Mike Braun (R-Ind.), who campaigned closely with Trump in the midterms, like a pair of other Republican freshmen who unseated Democrats.

As Romney prepared to be sworn in, he brushed aside the blowback he has received the past two days.

“I’m not worried about what other people think about what I have to say,” he said. “I just want to hear what they have to say about their priorities and their perspectives.”

Republicans will hold a 53-to-47 majority over the Democratic Caucus in the Senate. Republican Rick Scott, who is serving out his term as governor of Florida, will join the chamber next week.

As Vice President Pence swore in the new Senate, the tension that has roiled the upper chamber of Congress in recent weeks gave way to smiles, handshakes, hugs and applause.

But the reality of the shutdown and other battles to come quickly came back into view.

After opening the new session on a bipartisan note, declaring that “the American people need Democrats and Republicans to work together,” McConnell quickly dismissed the House Democratic plan to end the shutdown as “political theater; not productive lawmaking.”

Schumer, meanwhile, pointed squarely at the White House: “Only one person is to blame for this predicament: President Trump.” He called on McConnell to bring up the House Democratic bills, which would fund the Department of Homeland Security at current levels through Feb. 8 and ensure money for the rest of the government through the end of September in accordance with previous Senate designs.

“What is the rationale for keeping eight Cabinet departments shuttered for an unrelated dispute over the wall?” Schumer asked. “There is none. We can continue to debate the best way to secure our border.”

On the House side, McCarthy gave this assessment of the political moment: “What an amazing, invigorating and sometimes frustrating experiment this is — representative democracy,” he said before handing Pelosi the gavel.