(Updates with latest developments in Kiev)
KIEV, Feb 21 (Reuters) - Four years ago next Tuesday, Viktor Yanukovich was sworn in as Ukraine's president, sweet vindication after his first election victory was reversed in 2005 by the largely peaceful Orange Revolution.
Now, after dozens of deaths in Ukraine's worst violence since the collapse of the Soviet Union in 1991, Yanukovich faces mass protests that have put armed police to flight and brought pressure from allies in Moscow to reassert his control.
How did this country of 46 million, a territory the size of France that is the "breadbasket of Europe", get to this point?
IT'S THE ECONOMY
Despite vast prairies and an industrial base in the eastern coalfields, Ukraine's economy has struggled since communism crashed, leaving nominal GDP per head barely a quarter that of resource-rich Russia and half that of the poorest EU state.
Under Yanukovich's pro-EU predecessor Viktor Yushchenko, an economy dominated by business "oligarchs" made little progress in curbing corruption or generating growth, and feuding with Russia led to two "gas wars", when Moscow cut off energy supplies.
Yanukovich's victory in 2010 and that of his Party of the Regions in a parliamentary election in late 2012 were followed by negotiations with the IMF on budget support, but IMF demands for unpopular market reforms saw those talks falter last year.
With growing budget and trade deficits, and debt repayments approaching, public finances have been heading for bankruptcy.
WHAT SPARKED THE PROTESTS?
Popular hopes of economic improvement were raised by plans to sign a wide-ranging free trade and association agreement with the European Union at the end of November. Yanukovich had resisted EU demands that he free Yulia Tymoshenko, his pro-EU opponent jailed in 2011, but a deal still appeared imminent.
Russian President Vladimir Putin was not happy, and Moscow, which buys more than half of Ukraine's exports, threatened to shut borders and pipelines if Yanukovich signed up with the EU.
On Nov. 21, he rejected it, and tens of thousands of people took over Independence Square in central Kiev in protest.
WHO IS PROTESTING?
There are three leaders: Arseny Yatsenyuk, parliamentary chief of Tymoshenko's Batkivshchyna (Fatherland) party; former world champion heavyweight boxer Vitaly Klitschko of UDAR (Punch); and Oleh Tyahnibok of Svoboda (Freedom), a far-right nationalist group accused of racism and anti-Semitism.
They have strong support in Ukrainian-speaking western regions and among urban middle classes frustrated by graft.
Having started with demands for closer ties to the EU, the opposition now wants Yanukovich, 63, to at least share power or step down. They accuse him of selling out Ukraine to Russia and of enriching himself and allies in his native, Russian-speaking east, where he worked as an electrician after a troubled youth that included two spells in prison for theft and assault.
Armed militants, many from far-right groups, in military helmets, have emerged on the frontline of barricades. Calling themselves the Right Sector, they are uncompromising in their hatred and are involved in the bloodiest clashes with police.
HOW HAS YANUKOVICH RESPONDED?
He turned to Putin and secured a pledge of $15 billion in loans as well as cheaper gas prices after turning his back on the EU, bailing out the economy but further angering opponents.
He brushed off their demands, but confrontation heightened when parliament pushed through new laws curbing protest and civil rights. Several were killed in days of fighting on barricades around Independence Square, or Maidan, from Jan. 19.
Caught between the West and Russia, he repealed the new legislation, offered amnesty to those detained and removed Russian-born Prime Minister Mykola Azarov. However, opposition leader Yatsenyuk turned down an offer to take over as premier.
This week he has said he is open to dialogue and elections.
WHAT'S AT STAKE?
The showdown over Ukraine is about re-ordering power and influence in Europe following the Soviet collapse, and more broadly about Moscow's push to reassert itself in the world, particularly in relation to Cold War rival the United States.
EU and NATO enlargement eastward to embrace much of the old Soviet bloc with membership or alliances has fanned Russian irritation at encroachment on its "near abroad". Putin hopes in turn to form a Eurasian customs union, including Ukraine, a major market and historic cradle of Russian national identity.
Kremlin aides have also floated a federal Ukraine, in which the east might join Russia's zone, while the west would look to the EU.
For the European Union, especially Poland and others in the east, binding Ukraine - whose name literally means "borderland" - closer to its democratic values creates a buffer with Russia.
WHAT HAPPENS NEXT?
The United States and European Union have imposed limited, targeted sanctions that few diplomats expect to have much effect. Russia has made clear it wants Yanukovich to impose order if he wants to keep benefiting from financial support.
Following late-night talks brokered by EU foreign ministers, Yanukovich and the opposition were expected to sign a deal on Friday.
A senior EU diplomat said the agreement would involve constitutional reforms, including reduced presidential powers, to be implemented by September.
It was still unclear whether other opposition demands such as a transitional government and early elections were part of the deal.
The presidential press service had announced earlier on Friday that an agreement would be signed at noon but gave no further details.
This deal is key to easing the stand-off in the streets, which many feared over the last few days could bring the country to civil war and prompt a Russian intervention to protect people holding its passports, especially in the east and Crimea, where Moscow docks its Black Sea fleet.
Regional authorities in Lviv, close to the Polish border, declared self-rule this week, and further confrontation could foster separatism, though most Ukrainians say they want unity. (Reporting by Julien Toyer and Alastair Macdonald; Editing by Richard Balmforth and Will Waterman)
Our Standards: The Thomson Reuters Trust Principles.