FOR months, Kosovo, Macedonia and Albania have each been embroiled in crises of varying kinds. But over the past few days, the political landscapes in each of these countries have suddenly shifted, and for the better. Kosovar politicians who normally despise one another have struck a deal to campaign together in an election on June 11th. In Albania, a party that had been threatening for months to boycott elections agreed to take part. And Macedonia’s president at last agreed to let an opposing party form a government, ending a five-month-long impasse that had led to brawling in the streets and inside the country’s parliament itself.

The crisis in Kosovo was the most acute. On May 10th the country’s government fell when the Kosovo Democratic Party (PDK) of Hashim Thaci, the president, pulled out of the ruling coalition. The PDK wanted to hold elections before its declining popular support ebbed any further. The immediate cause of the collapse was the failure of parliament to ratify a border agreement with Montenegro. The fear was that in a country with a divided political class that has struggled to establish stability since declaring independence from Serbia in 2008, chaos might be in store.

Instead, on May 16th the PDK unexpectedly announced that it was forming a campaign coalition with two other significant political leaders, Fatmir Limaj and Ramush Haradinaj, a former prime minister. Both men have been tried for war crimes, and acquitted: along with Mr Thaci, they were commanders in the Kosovo Liberation Army (KLA), which fought Serbia in the war in 1998-99 that led to Kosovo’s secession. As president, Mr Thaci is now officially non-partisan, and the PDK is now headed by Kadri Veseli, a former commander in the KLA’s intelligence service.

The former KLA warlords are known to detest one another. But together, they stand a good chance of winning the upcoming elections. Any triumph may be short-lived: a new tribunal set up in The Hague to try war crimes and organised crime in Kosovo is expected to issue indictments later this year, and the report that led to its establishment mentioned all four of the leaders as possible targets of investigation. All deny any involvement in crime. In any case, most Kosovars have lost interest in international tribunals. They are worried about jobs, health care and education.

In Macedonia the crisis began after elections last December, when the conservative VMRO party, which had been in power since 2006, found itself unable to form a coalition. The president, Gjorge Ivanov, refused to ask the opposition Social Democrats and their ethnic Albanian allies to form a government, even though they had the votes in parliament to do so, calling them a threat to national security. They responded that VMRO leaders were afraid to give up power for fear of landing in jail on corruption charges.

On April 27th, VMRO deputies opened the doors of parliament to protesters, who stormed in and beat up Social Democrat deputies. If they thought this would help them hold on to power, they were mistaken. Under rising pressure from the European Union and America, the VMRO lost cohesion. On May 17th the president finally caved in and asked the Social Democrats to form a government.

In Albania, meanwhile, the opposition Democratic Party had maintained for the past three months that it would boycott the upcoming elections, now scheduled for June 25th. The ruling Socialists claimed the Democrats were afraid of losing. The Democrats riposted that the Socialists’ leaders were in league with drug smugglers, and would tamper with the results. Early on May 18th, the impossible abruptly became possible: leaders of both parties struck a deal to participate in the elections as planned.

In the past few weeks Kosovo, Albania and Macedonia have all been visited by the American assistant deputy secretary of state for the region, Hoyt Brian Yee. His visit may have had something to do with local politicians’ sudden openness to compromise. The European Union and the United States have become increasingly concerned by growing Russian influence in the region. They worry that conflict in the western Balkans could derail their other policies or even force them to intervene again, as they did in the 1990s. Despite recent improvements, the potential for chaos remains; they will need to stay involved.