* Yanukovich office says deal to be signed Friday
* EU sources say opposition seeks changes but expect deal
* Police say militants fire on them, lawmakers trade punches
* Death toll in two days violence reaches 77
* Ratings agency S&P downgrades Ukraine again (Adds opposition seeks changes, EU expects deal)
By Sabine Siebold and Natalia Zinets
KIEV, Feb 21 (Reuters) - Ukraine's pro-European opposition sought last minute changes to a deal with Russian-backed President Viktor Yanukovich intended to resolve the former Soviet republic's political crisis, but EU mediators said they still expect an agreement on Friday.
The German and Polish foreign ministers were in Kiev to try to broker an end to the worst violence since Soviet days amid a stand-off between riot police and anti-government protesters who have occupied a central square for nearly three months.
The sprawling nation of 46 million with a shattered economy and endemic corruption is at the centre of a geopolitical tug-of-war between Russia and the European Union.
Diplomats said a compromise drafted in all-night negotiations involved appointing a transitional government, with a reformed constitution by September reducing presidential powers, and fresh elections by the end of the year.
Whether such a gradual transition would be acceptable to grassroots activists who want Yanukovich out now was unclear.
"This is just another piece of paper. We will not leave the barricades until Yanukovich steps down. That's all people want," said Anton Solovyov, 28, an IT worker protesting in the central square.
A senior EU diplomat said the president and opposition leaders were expected to sign the deal on Friday, even though the opposition still wanted some changes.
Earlier, police said in a statement that anti-government militants fired on security forces near the central Independence Square, scene of a three-month-old protest vigil.
However, there was no independent confirmation of such an incident and no report of casualties.
The square, known as Maidan or "Euro-Maidan", appeared peaceful, with thousands of demonstrators chanting anti-government slogans interspersed with patriotic singing.
After the visiting ministers suspended talks at dawn, the presidential press service said an agreement with the opposition would be signed at noon (1000 GMT) but it gave no details. That time passed with no word of a signing.
SCUFFLES IN PARLIAMENT
Armed police briefly entered the parliament building while lawmakers were holding an emergency session but they were quickly ejected, opposition leader Arseny Yatsenyuk said.
Ukraine, a sprawling country of 46 million, faces the risk of civil war or even a break-up, and rage has spread even into the parliamentary chamber. Members exchanged punches when speaker Volodymyr Rybak tried to adjourn proceedings.
Opposition deputies were angered because it would mean delaying a possible vote on a resolution pressing for constitutional changes to restrict the president's powers. The speaker left the chamber and debate continued.
If signed and implemented, the deal would be a setback for Russian President Vladimir Putin, who has 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.
Polish Prime Minister Donald Tusk, whose foreign minister is one of the mediators, cautioned that there was only a tentative accord so far. "The agreement has not yet been reached. What's been settled is the agreement's draft," Tusk told reporters in Warsaw.
French Foreign Minister Laurent Fabius, who was involved in the mediation effort earlier in the night, said the opposition needed to consult.
"The opposition wants to consult with some of its members, which is entirely understandable," he told Europe 1 radio. "In this sort of situation, as long as things haven't really been wrapped up, it's important to remain very cautious."
After 48 hours in which the fate of Ukraine was fought out in the square, with at least 77 people killed, Yanukovich was rapidly losing support.
The deputy chief of the armed forces resigned and opposition deputies in parliament voted to overturn severe anti-terrorist laws enacted by Yanukovich's government this month and ordered security forces back to barracks.
In another sign of the severity of the crisis, 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 in the crisis made it less likely that Ukraine would receive desperately needed Russian aid. 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.
The health ministry said 77 people had been killed since Tuesday afternoon, which meant at least 47 died in Thursday's clashes. That was by far the worst violence since Ukraine's independence.
On Thursday, EU foreign ministers meeting in Brussels imposed targeted sanctions on Ukraine and threatened more if the authorities failed to restore calm.
In further diplomatic efforts, U.S. President Barack Obama spoke to German Chancellor Angela Merkel who in turn discussed Ukraine with Russian President Vladimir Putin. Moscow has strongly opposed what it sees as Western interference in Moscow's sphere of influence in Ukraine. (Additional reporting by Richard Balmforth, Alessandra Prentice, Vasily Fedosenko and Pavel Polityuk in Kiev, John Irish in Paris and Francesco Guarascio and Adrian Croft in Brussels; Writing by Paul Taylor; editing by David Stamp)