Ukraine, to its sorrow, has always been on the frontier between Russia and the rest of Europe. Its name even means "Borderlands". For centuries it was partitioned between its neighbours. When it gained its independence from the collapsing Soviet Union it was politically and linguistically divided between the Ukrainian-speaking West and the Russian-speaking East. Many observers in the early 1990s expected it to fall apart sooner or later. The first line of its national anthem seemed grimly appropriate: "Ukraine has not yet died".

Twenty years on, its independence and national identity seem more solid, even if many Russian politicians, from President Vladimir Putin to his arch-opponent Aleksey Navalniy, still talk of Russians and Ukrainians as "one people". But Ukraine, and the European Union, now face a moment of decision: will Ukraine be the Russosphere's border with the EU, or the Eurosphere's border with Russia?

Ukraine seemed for a long time to be dodging this choice: President Viktor Yanukovych tacked between Brussels and Moscow after his inauguration in 2010. Now, however, with the Vilnius Eastern Partnership Summit a month away, Ukraine seems to be turning decisively towards the EU - ironically, partly because of Moscow's pressure on it (described in Charles Grant's recent CER Insight 'Is Putin going soft?') to join the Russian-led Customs Union instead of signing an Association Agreement with the EU. Both government and opposition in Ukraine support closer integration with the EU, and opinion polls show that even in Russian-speaking eastern Ukraine there is a majority in favour of EU membership (though this is not on offer at this stage).

The deal is not yet done: the EU set a series of conditions for Ukraine to meet before the agreement could be signed. It has made some progress, for example on electoral reform, following EU criticism of the conduct of parliamentary elections in October 2012. The biggest obstacle remains, however: ending ‘selective justice', and in particular pardoning former Prime Minister Yulia Tymoshenko, currently serving a seven-year sentence for abuse of office. Former Polish President Aleksander Kwasniewski and former European Parliament President Pat Cox have been working persistently on behalf of the European Parliament (where Tymoshenko has many supporters) to achieve this.

Up to now, this has remained too much for President Yanukovych to swallow. The Ukrainian government has a draft law prepared which would release her on humanitarian grounds and allow her to travel abroad for medical treatment; but it would not void her conviction. Yanukovych evidently still considers her a political threat, and hopes that his compromise offer will be enough for the EU.

So far the EU has not blinked: Enlargement Commissioner Stefan Füle, Swedish Foreign Minister Carl Bildt and EP Foreign Affairs Committee Chair Elmar Brok all delivered the EU message to Yanukovych at the Yalta European Strategy meeting in September. The EP has extended the mandate of Kwasniewski and Cox for a few more weeks in the hope that they can still clear the way for Ukraine to sign the Association Agreement, which includes a Deep and Comprehensive Free Trade Agreement (DCFTA), in Vilnius. As an incentive, both the Parliament and the Council have supported provisional application of the trade aspects of the agreement as soon as possible after signature, prior to ratification.

Assuming that a solution is found, both Ukraine and the EU will face challenges in implementing the agreement and benefitting from it. For Ukraine, the immediate threat is that Russia will punish it for rejecting the Customs Union. Russia has repeatedly used gas deliveries to Ukraine and other neighbours as instruments of political pressure. When Deputy Prime Minister Dmitriy Rogozin recently warned the Moldovans against initialing their own Association Agreement with the EU, telling them that he hoped they would not freeze, Ukraine will have got the message.