California lawmakers will finally vote Friday on the plan to start building the state’s high-speed rail project, and in a surprise twist, money for the polarizing bullet train will be tied to a deal that would save the popular Caltrain commuter service.

Gov. Jerry Brown’s final bullet train funding proposal released Wednesday includes the last $705 million needed to electrify the existing train line between San Francisco and San Jose. The Caltrain money was supposed to be debated next year as a separate plan.

The money would fully fund a long-coveted Caltrain overhaul designed to steer the local agency away from bankruptcy, allowing it to emerge later this decade with cheaper and more frequent commuter service. It also would lay the groundwork for statewide bullet trains to zip through the Bay Area next decade.

Along with $500 million for upgrades in Los Angeles, Brown’s final $8 billion proposal is designed to appease everyone in the state at a time when tensions over the bullet train are higher than ever. The centerpiece of the deal is nearly $6 billion to lay the first high-speed rail track in the Central Valley early next year, the first step needed to build the entire $69 billion railroad that would connect San Francisco and Los Angeles by 2030.

“The Legislature wanted to emphasize that this money would be there for (the Bay Area and Southern California). And they’re right,” said Dan Richard, whom Brown appointed to lead the bullet train project. The Legislature is poised to vote on the proposal Friday morning after hearings Thursday. Lawmakers are under intense pressure from the Obama and Brown administrations, and Democratic leaders from state Senate President Pro Tem Darrell Steinberg to U.S. House Minority Leader Nancy Pelosi, to approve the plan.

The Assembly intends to approve the project. But in the Senate, the plan was at least a half-dozen votes short of passing as of the July 4 holiday, though Democrats led by Steinberg were believed to be on the verge of rounding up enough votes to launch construction. The project is expected to pass in some form, though there is a last-minute showdown over where construction should start.

“I’ve indicated a willingness to support it, and I consider myself a supporter of high-speed rail done right,” said state Sen. Joe Simitian, D-Palo Alto, a key swing vote. “For me, the final question is not about the vision of high-speed rail but a practical one about whether we have a plan that makes sense for California.”

Completing the Caltrain “modernization” effort after more than a decade of planning would, in theory, allow the commuter line to overcome its ongoing financial woes by starting construction early next year and launching service with faster, cheaper, greener trains by 2019. Next decade, statewide bullet trains would share the two tracks on their way to Los Angeles.

“Without this, electrification will be a long way off,” said Caltrain board chair Adrienne Tissier. “I don’t know how much longer Caltrain can last” without electrifying.

Though the Caltrain funds were expected at some point in the next decade, tying the money for the popular project now to high-speed rail — which faces stiff opposition in the Peninsula — puts tremendous pressure on conflicted Bay Area legislators.

“This isn’t free money,” said state Sen. Mark DeSaulnier, D-Concord, who is still against the plan despite his support for the Caltrain project because “I can’t vote to spend $6 billion” in the Central Valley.

For Friday’s high-speed rail vote in the Senate, the breakdown is simple. All 15 Senate Republicans oppose the current plan. That leaves the 25 Democrats, and at least 21 are needed to approve the bullet train. At least a dozen are believed to be on board, and virtually all of the rest are on the fence.

The biggest remaining issue is where to start building.

The federal government over the past three years has given California $3.3 billion to start building high-speed rail in the Central Valley. But in the past year, opposition has poured out of the agricultural center of the state while critics in big cities around the nation have decried it as a “train to nowhere.”

As a compromise, some lawmakers led by DeSaulnier have in the past week proposed a “Plan B” to split the money into the three regions, with San Francisco, Fresno and Los Angeles getting about $1 billion each for local transit projects that would lay the groundwork for high-speed rail. In the Bay Area, for instance, they would build a short tunnel between the end of the Caltrain line in San Francisco and the new Transbay Terminal downtown, to be used by both Caltrain and state bullet trains.

But Brown, the federal government, Senate leadership, business groups and labor unions are pushing hard to lay the big, connected stretch of track in the Central Valley, saying it is the best road map toward constructing the entire railroad because it would be harder to abandon.

“It’s going to be very hard to come back in 10 years and build that Central Valley segment at the same cost,” said Michael Cunningham, vice president of the pro-business Bay Area Council, one of the groups fighting Plan B. By building now, “you have that in the bank.”

Brown’s $8 billion plan also includes several new oversight provisions that would allow lawmakers to pull the plug on funding during construction if they are not satisfied. Rounding out the proposal are $714 million for local transit projects designed to connect to a future high-speed rail line and $253 million set aside for planning and property acquisition needed to clear space for the train line.

About $4.7 billion will be paid by voter-approved bond funds, along with the $3.3 billion from the federal government. It is still unclear where the remaining funding for the entire $69 billion project will come from.