The Biden administration reached an agreement with Germany on Wednesday that allows for the completion of a controversial natural gas pipeline between Russia and Germany, ending a heated dispute between the two allies that overlapped three successive U.S. administrations.

In exchange for an end to U.S. efforts to block the Nord Stream 2 pipeline, Germany will invest in Ukraine’s green technology infrastructure, and Berlin and Washington will work together on initiatives to mitigate Russia’s energy dominance in Europe.

The decision drew immediate criticism from Russia hawks in Congress who hoped the United States could find a way to block the nearly completed multi­billion-dollar project they say gives Moscow leverage over U.S. allies in Europe.

“This is a generational geopolitical mistake that decades from now future Russian dictators will be reaping billions of dollars of benefits annually from,” said Sen. Ted Cruz (R-Tex.).

The Biden administration viewed the project as a dilemma that forced it to choose between restoring its beleaguered relationship with Berlin and keeping its public promise to oppose the project, which was 90 percent complete when President Biden took office. U.S. officials doubted that U.S. sanctions could prevent its completion and argued that a deal with Germany rather than a protracted fight offered the best outcome.

“Look, this is a bad situation and a bad pipeline,” Victoria Nuland, the No. 3 official at the State Department, told senators in Washington on Wednesday. “But we need to help protect Ukraine. And I feel that we have made some significant steps in that direction with this agreement.”

The Senate Foreign Relations Committee’s top Republican, James E. Risch (Idaho), said he would continue to pursue sanctions legislation in an effort to block the project.

“Congress must act where the administration has failed, and I will continue working with colleagues on both sides of the aisle to impose meaningful costs on this malign Russian project before it becomes operational,” he said in a statement.

The four-point agreement includes a commitment by Germany to create and administer a $1 billion green technology fund for Ukraine designed to promote renewable energy, facilitate the development of hydrogen and accelerate the country’s transition away from coal, said a senior administration official who spoke on the condition of anonymity to discuss details of the deal.

To jump-start the fund, Germany will provide at least 150 million euros, or about $177 million, the official said.

Because the Nord Stream 2 pipeline circumvents Ukraine, a current transit partner with Moscow, Kyiv could lose some $2 billion in annual payments from Moscow as part of a transit contract for Russian gas that’s set to end in 2024.

In an effort to stave that off, Germany agreed to appoint a special envoy to help Ukraine negotiate an extension of its transit contact with Russia up to 10 years, the senior administration official said. “Germany is committing in writing to use all of its available leverage to negotiate that agreement,” the official said.

Germany also agreed to press for sanctions in the event Russia attempts to use its energy clout as a weapon against Ukraine, according to the joint statement signed by Washington and Berlin.

Ukrainian officials say their primary concern is the Kremlin feeling more emboldened in its dealings with Kyiv in the event that it no longer serves as a transit space for Russian gas. Ukrainian forces are in regular battle with Kremlin-backed separatists in Eastern Ukraine where efforts to negotiate an end to the seven-year-old war have long stalled.

In an attempt to smooth over the decision, State Department Counselor Derek Chollet traveled to Kyiv on Tuesday to discuss the issue. He then travels to Warsaw to discuss the policy with Polish officials, who have also been critical of the Russian pipeline. The topic is likely to come up during Ukrainian President Volodymyr Zelensky’s meeting with Biden in Washington next month, which the White House announced on Wednesday.

The Biden administration’s decision effectively ends speculation on the fate of the project, which Russian President Vladimir Putin said last month would be completed by August. In his remarks at the St. Petersburg Economic Forum, he said the project was “purely” a commercial and economic project with no geopolitical dimensions.  

Kremlin spokesman Dmitry Peskov said Wednesday that Russia would never use gas and oil as levers of political pressure. But last month Putin warned that Ukraine would have to show “good will” if it wanted gas transit to continue.

Inside the Biden administration, the decision to give up on blocking the pipeline culminated with a contentious debate in May over whether to withhold sanctions against the company and CEO behind the project.

The State Department, in a position backed by Secretary of State Antony Blinken, his deputy Wendy Sherman and Nuland, recommended sanctioning the company and CEO, said officials familiar with the decision.

Biden, backed by top aides on the National Security Council, disagreed, arguing that the move would inflame relations with Germany, a key ally that views attempts to block the pipeline as a violation of its sovereignty. White House officials viewed the project as a fait accompli that was not worth jeopardizing the U.S.-Germany relationship over.

While critics in Washington say the pipeline could increase Russia’s leverage over Europe, some scholars view the dispute as a relic of the energy wars of the 1990s, given Europe’s continued march toward renewable energy. “Critics haven’t noticed that the European Union has over recent years effectively solved its energy security problems and that it will soon start to phase out natural gas as part of its green transition,” said Jeremy Shapiro, research director at the European Council on Foreign Relations.

“The Biden administration by contrast recognizes that the United States has more important foreign policy problems than a faraway pipeline, not the least of which is the geopolitical competition with China,” he added. “Those problems require a strong alliance with partners like Germany.”

Karen DeYoung in Washington, Robyn Dixon in Moscow and David Stern in Mukachevo, Ukraine, contributed to this report.