* Unsmiling Yanukovich signs deal with opponents
* Parliament changes constitution, sacks interior minister
* Criminal code amended to allow Tymoshenko release
* EU mediators says deal gives peace a chance
* Early presidential election this year
By Sabine Siebold and Natalia Zinets
KIEV, Feb 21 (Reuters) - Ukraine's opposition leaders signed an EU-mediated peace pact with President Viktor Yanukovich on Friday, winning a raft of concessions in a delicate deal to end violence that killed at least 77 people and turned the capital into a battle zone.
By nightfall, opposition leaders who signed the deal were addressing peaceful crowds from a stage in Independence Square, which for the past 48 hours had become an inferno of blazing barricades, where protesters were shot dead by police snipers.
But the crowd was still defiant, holding aloft open coffins of slain demonstrators and making speeches denouncing the opposition leaders for shaking hands with Yanukovich.
If it holds, the deal - hammered out with the mediation efforts of the foreign ministers of France, Germany and Poland - would mark a victory for Europe in a tug-of-war with Moscow for influence in the divided ex-Soviet state of 46 million people.
But it remains to be seen whether violence can be halted and whether a lurch away from Moscow will cost Ukraine a $15 billion Russian financial lifeline it needs to stave off bankruptcy.
Under pressure to quit from mass demonstrations in Kiev, Russian-backed Yanukovich agreed to create a national unity government, change the constitution to reduce his powers and leave office early for new elections.
"There are no steps that we should not take to restore peace in Ukraine," the president said in announcing his concessions before the agreement was signed. "I announce that I am initiating early elections."
Within hours, parliament voted to revert to a previous constitution slashing Yanukovich's prerogatives, sacked his interior minister blamed for this week's bloodshed and amended the criminal code to pave the way to release his rival, jailed opposition leader Yulia Tymoshenko.
EU leaders and the White House praised what European Council President Herman Van Rompuy called a "necessary compromise". Moscow made grudging comments that fell short of endorsing the deal. The European envoys signed the document as witnesses, but a Russian envoy did not.
That envoy, Vladimir Lukin, acknowledged that Moscow had fallen behind the EU in the latest diplomacy: "The EU representatives were in their own way trying to be useful, they started the talks.
"We joined the talks later, which wasn't very right. One should have agreed on the format of the talks right from the start," Lukin was quoted as saying by Interfax news agency.
Yanukovich, 63, a towering former Soviet regional transport official with two convictions for assault, did not smile during a signing ceremony at the presidential headquarters. Opposition leader Vitaly Klitschko, a retired world boxing champion, switched his nameplate to avoid sitting next to the president.
Polish Foreign Minister Radoslaw Sikorski described the agreement as a "good compromise for Ukraine". It "gives peace a chance. Opens the way for reform and to Europe," he tweeted.
It fell to Sikorski to sell the deal to the sceptical opposition. ITN video filmed outside a meeting room during a break in the talks showed him pleading with opposition delegates to accept it: "If you don't support this, you'll have martial law, you'll have the army, you'll all be dead."
PROTESTERS STAND THEIR GROUND
Anti-government protesters remained encamped in Independence Square, known as the Maidan or "Euro-Maidan", and made clear their dissatisfaction at a deal that would leave Yanukovich in power until the early elections later this year.
Shortly after the signing ceremony, an open coffin carrying one of the dead from Thursday's violence, was borne across the square as a bare-chested drummer beat out a funeral tattoo with people chanting "Heroes don't die! Bandits out!"
Some car horns hooted and fireworks were lit to celebrate the accord, but many activists were suspicious, noting that Yanukovich had cut deals before and was still in office.
When the three opposition politicians who signed the deal addressed the crowd in the evening, another coffin carrying a victim was borne through the crowd to the stage, apparently catching the leaders off guard. After another open coffin was held aloft by the crowd, a protester wearing battle-fatigues leapt to the microphone in front of the opposition leaders.
"My comrade was shot and our leaders shake the hand of a murderer. It's a disgrace!" he said to roars of approval. "If it is not announced by 10:00 tomorrow that Yanukovich is gone, we're going to attack with weapons."
Earlier Klitschko drew cat-calls and derisive whistling from the crowd when he praised as "very important" their political achievements during the day. He later apologised for shaking Yanukovich's hand, telling the crowd: "If I offended anyone, I ask their forgiveness."
That wasn't enough for 35-year-old Volodymir from the western city of Lviv near the Polish border: "We won't follow Klitschko and the rest of them. They shook hands with a gangster and danced with the devil."
POLICE IN PARLIAMENT
Earlier in the day, armed police briefly entered the parliament building while lawmakers were in emergency session but were quickly ejected. Members traded punches when speaker Volodymyr Rybak tried to adjourn proceedings.
If fully implemented, the deal would be a severe setback for Russian President Vladimir Putin, who had made tying Ukraine into a Moscow-led Eurasian Union a cornerstone of his efforts to reunite as much as possible of the former Soviet Union.
Moscow has maintained that the protesters were terrorists and coup plotters, had denounced the West for supporting them and encouraged Yanukovich to crush them.
"This is not democracy, this is anarchy and chaos. And we'll see what comes out of it," Alexei Pushkov, head of Russia's State Duma foreign affairs committee and a member of Putin's United Russia party told Reuters, although he said the accord would be positive if it ended the violence.
Washington took a back seat in the final phase of negotiations after a senior U.S. official was recorded using an expletive to disparage EU diplomacy on an unsecured telephone line last month.
The future of Ukraine's economy, heavily indebted and dependent on Moscow for energy imports, remains unclear. Putin had promised $15 billion in aid after Yanukovich turned his back on a far-reaching economic deal with the EU in November, and Russia has not made clear whether it will still pay.
Ukraine cancelled a planned issue of 5-year Eurobonds worth $2 billion, it told the Irish Stock Exchange where the debt would have been listed. Kiev had hoped Russia would buy the bonds to help it stave off bankruptcy.
Ratings agency Standard & Poor's cut Ukraine's credit rating for the second time in three weeks on Friday, citing the increased risk of default. S&P said latest developments made it less likely that Ukraine would receive Russian aid.
RBS analyst Tatyana Orlova noted the country was still in dire financial straits. "This is not the end of the story. What I am reading is there is a deal but the devil is in the detail ... The urgent need is for a technocratic cabinet that could take steps to avert default," Orlova said. (Additional reporting by Richard Balmforth, Alessandra Prentice, Vasily Fedosenko and Pavel Polityuk in Kiev, Sujata Rao in London, Alexei Anishuk in Moscow, Leigh Thomas in Paris, Marcin Goettig and Adrian Krajewski in Warsaw, Alexandra Hudson in Berlin; Writing by Paul Taylor, David Stamp and Peter Graff; Editing by Robin Pomeroy)
Our Standards: The Thomson Reuters Trust Principles.