In just the past few weeks, two examples emerged to demonstrate the harmful consequences when political leaders overplay their hand and provoke harsh responses. One occurred in Iraqi Kurdistan, the other in Spain’s Catalonia region. Both entities now teeter on the brink of calamity. There also are pertinent lessons from those episodes for U.S. policymakers.

Despite abundant warnings from multiple sources, the Kurdistan Regional Government (KRG) in Erbil held a referendum on September 25 regarding independence from Iraq. President Masoud Barzani’s administration should have realized even before the vote that matters were not likely to turn out well. Not only did Iraq’s Prime Minister Haider al-Abadi make it clear that such a referendum was unacceptable and would lead immediately to retaliatory measures, but neighboring states, including Iran, Syria and Turkey, did so as well. Even the United States, which regards Kurdish fighters in both Iraq and Syria as extremely valuable allies in the struggle against ISIS, urged the KRG to exercise more caution.

Barzani and his colleagues ignored such signs of trouble and went ahead with the balloting. The results were predictable, with more than 90 percent of voters favoring independence. Both Baghdad and Tehran immediately closed air-traffic corridors into landlocked Kurdistan, and those governments, together with Turkey, began to coordinate policies to rein in the KRG. Abadi’s regime was the most proactive, immediately dispatching troops to seize the disputed, oil-rich city of Kirkuk and other sites in northern Iraq. Peshmerga units (the KRG’s army) had to abandon Kirkuk and retreat ignominiously from the other areas that were under siege.

Within mere weeks after the bold referendum, the KRG had lost much of what it had gained in the years since it established a highly autonomous foothold in Iraq’s predominantly Kurdish region following the fall of Saddam Hussein in 2003. Iraqi Kurdistan had become independent in nearly everything but name. It had its own army, flag and currency, and it largely controlled the export of oil from northern Iraq. Baghdad’s sovereignty over the region was minimal and tenuous. The KRG even had been successful in exploiting the ISIS threat and the setbacks that Baghdad suffered to establish control over Kirkuk, a long-standing Kurdish objective.

Prudent statesmanship would have dictated leaving well enough alone and consolidating those gains. Instead, Erbil reached for full, formal independence. That was a provocation that neither Baghdad nor any of the other capitals could let go unchallenged. The Kurds are the largest distinct population in the world without a homeland, and major portions of that ethnic bloc are present in Iran, northern Syria and especially Turkey (some 50 percent of the total), as well as northern Iraq. An independent Kurdistan is seen as a threat to the territorial integrity of all of those countries. Therefore, there was no chance whatsoever that they would tolerate the results of Erbil’s independence referendum.

Retaliation was predictable, yet the KRG went ahead even though it lackedsufficient military power to repel hostile forces and sustain its claim. At a minimum, it would have been necessary to build up the power of the peshmerga enough to pose a credible deterrent to coercive measures. Patiently extracting more high-powered weaponry from Washington in exchange for Erbil’s continued valuable assistance against militant Islamic groups would have been a productive course. Instead, Barzani’s government acted precipitously. In essence, his regime overreached and wrote geopolitical checks that bounced. Now, many of the hard-won gains since 2003 are probably lost—and perhaps lost forever.

Advocates of Catalonia’s independence from Spain appear to have made a similar blunder. Sentiment for independence has been building in that region for decades, and the regional government decided to hold a referendum regarding that option on October 1. As in the case of Kurdistan, there were clear warnings not to go down that path. The central government in Madrid was emphatic that such a move would not be tolerated. Indeed, the Spanish authorities sent police and other security personnel to prevent the balloting. That move led to ugly incidents in which those units behaved in a barbaric fashion, beating hundreds of mostly peaceful pro-independence demonstrators in Barcelona.

Despite such actions, the referendum went forward and produced an outcome favoring independence. Spanish authorities have since greatly hardened their stance. Madrid’s first demand was for Catalonia to hold new elections to replace the existing regional government. When the Catalans refused, and instead issued a declaration of independence, the Spanish parliament voted to oust officials of that government and to dissolve the elected regional legislative body. The vote also granted the prime minister unprecedented authority under the Spanish constitution to put down the rebellion. Through more subtle means, the Catalans might have achieved greatly enhanced autonomy for their region. By boldly pushing for independence, they are in danger of being subjected to harsh repression from Madrid. As in the case of Kurdistan, overreaching has led to a severe setback at a minimum and potential disaster at worst.

One might think that U.S. leaders are perceptive enough to avoid similar folly, but the record suggests otherwise. The United States achieved its initial objectives in Afghanistan, routing Al Qaeda, ousting the Taliban regime that had given that terrorist group safe haven and eventually killing Osama bin Laden. However, Washington was not content with such modest but important accomplishments. Instead, U.S. leaders prolonged and escalated America’s military intervention. They also changed the objective from punishing and defanging Al Qaeda to a murky counterinsurgency and nation-building mission. The predictable result is a war now in its sixteenth year, with little prospect of achieving those impractical goals.’

The Trump administration shows signs of similar overreach with regard to policy toward Iran. President Obama wisely collaborated with other international powers to negotiate the Joint Comprehensive Plan of Action with Tehran to limit Iran’s nuclear program. By all reasonable accounts, the plan is working and Iran’s program remains under severe restraints that would prevent a breakout to build nuclear weapons. But President Trump, succumbing to the blandishments of ultra-hawkish Iranophobes, has refused to certify Iran’s compliance with the JCPOA, opening the door for new U.S. sanctions and the possible torpedoing of the agreement. Once again, the United States flirts with overreaching, undoing an agreement that is working well, and creating the prospect of a renewed, very dangerous crisis with Iran.

Wise officials in any country need to resist the temptation to overreach, thereby jeopardizing existing achievements and the potential for modest additional gains. Veteran Wall Street investors have a saying: “bulls make money, bears make money, but pigs get slaughtered.” Political leaders should heed a similar admonition.