House Minority Leader Nancy Pelosi (D-Calif.) prepares to leave a news conference on Thursday. Democrats could tank President Obama’s trade legislation when it comes up for final votes Friday. (Pablo Martinez Monsivais/AP)

President Obama’s trade initiatives headed toward a decisive showdown Friday with little margin for error, as his regular allies on Capitol Hill mounted a furious last-ditch effort to derail a key vote and anxious Republicans tried to gather support for a White House that has normally been their deepest enemy.

Obama’s top advisers shuttled up and down Pennsylvania Avenue Thursday in a bid to shore up Democrats, fearful that the fallout from a defeat at the hands of the president’s own party would leave Democrats an internal feud for weeks on end.

Republicans remained focused on trying to pry loose votes from rank-and-file conservatives who otherwise support expanded trade but have made a political living off bashing the Democratic president. During a critical vote Thursday evening, 34 Republicans opposed their leadership and nearly sabotaged the debate before it even formally started, but eight Democrats broke ranks to set the stage for a pair of Friday votes that will determine the outcome of Trade Promotion Authority.

When the gavel fell, giving Obama and Republicans an early win, Rep. Paul Ryan (R-Wis.) pumped his arm, fist-bumped three Republicans around him and high-fived another. The chairman of the Ways and Means Committee, Ryan served as his party’s 2012 vice-presidential nominee and lead critic of Obama’s first-term agenda.

Leaders in neither party expressed confidence in what could be a razor-thin margin during Friday’s votes, with House Speaker John A. Boehner (R-Ohio) merely saying that he will match the vote total that he has privately promised Obama.

“We’ll do our part,” Boehner told reporters Thursday.

Upward of 200 Republicans could support the president, and about 20 Democrats have publicly pledged their support — a total that would just barely clear the majority needed to send the legislation to Obama’s desk for his signature.

The centerpiece of the legislation would grant the president six years of “fast track” authority to freely negotiate trade accords, limiting Congress’s role in their approval to a simple up-or-down vote. Obama has said he needs this authority to negotiate the final details of the Trans-Pacific Partnership, so the other nations know that Obama can submit the deal without congressional tinkering.

Unions have argued that another round of trade deals will lead to more offshoring of jobs and depress wages at home. Vote counts remained fluid on each side, but by late Thursday the focus — from the Capitol corridors to the West Wing — had narrowed to the most liberal faction of House Democrats.

Top Obama administration officials, including White House Chief of Staff Denis McDonough, Treasury Secretary Jack Lew and Labor Secretary Thomas Perez, were summoned to the Capitol by House Minority Leader Nancy Pelosi (D-Calif.) to address skeptical Democrats on Thursday. In an unusual setup, the presidential team addressed the Democrats in a closed-door basement meeting room, and after they left, Democrats then heard from Richard Trumka, president of the AFL-CIO.

Late Thursday afternoon, McDonough hurried back to the Capitol for another meeting with Pelosi.

The debate has laid bare the deep division among Democrats on economic policy, with an increasingly vocal coalition of liberal activists saying that increased global trade benefits multinational corporations while doing little for the middle class.

The battle has pitted friend against friend, nowhere more so than Pelosi and Rep. Rosa L. DeLauro (D-Conn.), the fiery liberal from New Haven who has girded for this fight for two years. Italian grandmothers who are close friends, Pelosi and DeLauro fought in private during a leadership meeting Wednesday night over the tactics DeLauro and her union allies were deploying to defeat the legislation, according to several senior Democrats.

By Thursday’s votes, the duo held an animated discussion in public on the House floor.

Pelosi has kept her plans close to the vest throughout this process, but those close to her and White House advisers say that she does not want to see Obama’s agenda fall at the hands of Democrats. DeLauro is leading the charge against trade with an approach that some Democrats view as any means necessary.

The final wrangling among Democrats is not focused on the trade authority, but instead on a related provision that would provide financial assistance to workers and communities harmed by foreign trade deals. That Trade Adjustment Assistance legislation, or TAA, has historically won wide support among Democrats, and its inclusion alongside fast-track authority has typically helped persuade skeptical Democrats to support the overall package.

But DeLauro and her allies threatened to oppose the pending TAA bill, raising concerns about a provision that would pay for the trade assistance by cutting Medicare, as well as language keeping public employees from claiming benefits. And the AFL-CIO has led the outside effort to oppose TAA in a tactical move to kill the wider deal.

After a series of modifications made at Pelosi’s request, Republicans unveiled a compromise that replaced the Medicare cut with increased tax revenue and laid out a voting process that suited the Democratic leader.

“The substitute that we have is a good one,” she told reporters early Thursday.

There will be two votes — one for the trade authority, expected to receive huge GOP support and some Democratic support, and one for worker assistance, which would normally garner huge Democratic support and some Republican votes.

Despite Obama’s efforts, some Democrats opposed to the trade deal pushed to vote against their normal beliefs and take down the TAA vote, because that would then sabotage the broader trade agenda. “I’m voting against it because it’s a way to increase the chances for TPA,” said Rep. Sander M. Levin (D-Mich.), the ranking Democrat on the Ways and Means Committee.

Some Pelosi confidants predicted that most Democrats would eventually support a program that they believed in, making that vote anticlimactic. “Their brains may suggest that they should vote against TAA, but their hearts make it very difficult,” said Rep. Steve Israel (D-N.Y.).

Obama’s advisers warned that the funding authority for the worker assistance program expires later this year, and therefore sabotaging the broader trade agenda by voting down a program they otherwise believed in would also end a program that distributes federal aid to more than 2 million displaced workers.

“If you’re a member of Congress and you vote against trade adjustment assistance, you’re adding your name to the death certificate,” White House press secretary Josh Earnest said.

David Nakamura and Kelsey Snell contributed to this report.