Tucked away in the National Defense Authorization Act (NDAA) headed for President Trump’s desk after Senate passage this week are sanctions to delay completion of the Nord Stream 2 pipeline that ships Russian natural gas to Europe. On the surface, this has little to do with American national defense. So then why is it in the bill? Ukraine — and not for any reason tied to impeachment.

The Nord Stream 2 pipeline cuts Ukraine out of land-based transport of Russian gas that nets Ukraine over $2 billion annually in transit fees. The pipeline, which is almost 90 percent done, would generate billions of dollars for Russia and double Europe’s consumption of Russian natural gas.

Congress fears that Russia will use energy as a weapon to shape European politics while also weakening Ukraine and other Eastern and Central European countries. This isn’t the first time the United States has tried such an approach. In fact, Ronald Reagan tried a similar maneuver almost 40 years ago, but trampled upon European economic sovereignty in the process. The result was disastrous, but the debacle taught Congress key lessons it can now use today to develop a blueprint for a stable national security policy that would protect countries like Ukraine in the 21st century.

In late 1981, Reagan announced sanctions to prevent the completion of the Euro-Siberian gas pipeline that shipped Soviet natural gas overland to Western Europe. Sanctions initially applied to American companies such as Caterpillar and General Electric, ceasing the sale of American equipment and technology for pipeline construction.

Nevertheless, the pipeline construction used capital and technology from Europe that initially escaped the sanctions.

For Western Europe, in the midst of a deep recession, the pipeline was a boon. The project promised relief in the form of jobs and industrial orders for hard-hit industries in West Germany, Britain and France. Soviet natural gas also diversified Europe’s energy profile away from dependence on OPEC, amid OPEC’s price surges and oil shocks.

Economically, the pipeline made sense for European leaders. Diplomatically, however, it triggered a crisis between the United States and Europe.

Reagan and members of his administration viewed the issue through a Cold War lens and could not abide a Soviet win. The administration worried that the natural gas profits from the pipeline would increase the Soviet Union’s influence and allow the country to modernize its military. European allies rejected Washington’s reasoning and construction continued.

After failing to convince the United States’ NATO allies to adopt sanctions, Reagan took a risk by expanding the sanctions to European subsidiaries of American companies and applying them retroactively in an effort to stop the pipeline construction in its tracks. He hoped that Europeans would acquiesce to these unilateral sanctions.

Leaders in Bonn, Germany, and in London and Paris refused to bend and warned the Reagan administration that they would not surrender their sovereignty. Prime Minister Margaret Thatcher, one of Reagan’s staunchest allies, rebuffed him and told the BBC she felt “deeply wounded by a friend.”

Resolving the diplomatic crisis fell to Secretary of State George Shultz. He deftly brokered a solution that both convinced Reagan of the sanctions’ folly and mitigated European allies’ anger.

Less than a year after announcing the sanctions, the Reagan administration retreated and the Euro-Siberian Pipeline proceeded. Tensions cooled and relationships were rebuilt.

After the pipeline opened, European countries steadily increased their consumption of Russian natural gas. Germany — one of the world’s largest economies — became increasingly dependent on it to power its economic expansion as well as heat homes.

Today Germany is Russia’s primary foreign consumer. Almost a quarter of Germany’s energy needs are fulfilled by natural gas and nearly 90 percent of its natural gas is imported.

Crucially, Nord Stream 2 is projected to fill a shortfall from the closing of natural gas fields in the Netherlands that historically fueled Germany.

As Germany weans itself off coal-fired and nuclear power plants to meet sustainability and safety goals, the country’s appetite for natural gas is only slated to grow. The United States is concerned that Russia will meet those needs and increase its influence over Germany and the European Union. Growth of Russian influence could limit the E.U.’s willingness to confront Russia over political interference or back U.S. geopolitical objectives in Europe.

This creates a similar situation to the one facing Reagan in 1981. This time, however, Congress seems to have learned from Reagan’s mistakes. The breadth of the sanctions were what provoked so much European outrage in 1982. They threatened to dictate energy and economic policy to the United States’ European allies.

By contrast, the sanctions in the NDAA are far narrower and more targeted. They focus on the few companies with the capacity to lay the remaining pipes for Nord Stream 2. The stringent sanctions pack enough bite to keep these companies from defying them, and they also target individuals, like company executives, who use American financial markets.

But unlike Reagan’s sweeping sanctions, these do not go after Nord Stream 2’s investors such as Royal Dutch Shell or industries that could damage a national economy.

The result is that silence has largely characterized the response of many E.U. member-states to the sanctions. Even though Chancellor Angela Merkel condemned them, she also indicated Germany would not retaliate with counter sanctions.

In short, for now, natural gas will continue to flow via Ukraine, which could pay great dividends for the country, economically as well as diplomatically as it works to secure peace with Russia.

Equally importantly, pressure from sanctions could convince Merkel and the E.U. to advocate for a lasting transit fee that benefits Ukraine when Nord Stream 2 eventually opens. Doing so would demonstrate the E.U.’s commitment to frustrate Russia’s bids to dominate Ukraine and its neighbors, and show common purpose against Russian geopolitical ambitions.

If sanctions work to tangibly benefit Ukraine, Nord Stream 2 may provide a case study for how the U.S. can protect vital partners and cooperate with allies in a new era of great power competition and lay a foundation for stable national security policy.

The United States must not pursue sanctions or policies that drive allies into the hands of geopolitical rivals, like Russia and China. This means avoiding the Reagan administration’s mistake of asserting control without considering allies’ priorities. At the dawn of a new global order, sanctions and similar measures must, and as the Nord Stream 2 case indicates, can, however, be utilized strategically to build resilient alliances that protect the interests of allies and partner states while confronting strategic competitors.