Greece’s two main political parties reached an agreement late Sunday to form a unity government, giving Europe a steadier partner as it works to avert a larger financial crisis on the continent.

Prime Minister George Papandreou will resign after the new government is formed, officials said, although the timing, and who will be his successor, remained unclear.

The move brings Greece a step closer to stability after a political crisis last week threatened its future in the euro zone and raised the prospect that debt crises in other, larger countries could soon follow. The economies of Spain and Italy have been sputtering in recent weeks, and world leaders fear that if Greece failed to sign on to a bailout plan that was worked out late last month, it would trigger a bank run and market panic.

Papandreou and the head of the main opposition New Democracy party, Antonis Samaras, met late Sunday and agreed to form a coalition government that is expected to push through the bailout plan, with Papandreou pledging to step down, the office of the Greek president said Sunday. Talks will continue Monday as the two men decide on a new prime minister and cabinet, according to a statement released by the president’s office.

“I am not interested in staying on in this new government as prime minister,” Papandreou said at a cabinet meeting earlier Sunday, according to a transcript released by his office. “I couldn’t have been clearer. I don’t play games, and neither do I gamble the country’s fortunes.”

Greek politicians were under tremendous pressure to form a unity government before key European meetings Monday at which the country is supposed to start planning its fiscal future. European Union officials lashed out at the squabbling parties Sunday, urging them to end their deadlock. After they told Greece last week that its future in the euro zone was at stake, their words carry new weight in the country.

The agreement seemed likely to bring some measure of reassurance Monday to financial markets. But Asian stocks fell ahead of Sunday’s meeting of Greek leaders, with Japan’s Nikkei 225-stock average dropping 0.3 percent, South Korea’s Kospi Index sliding 0.1 percent and Australia’s S&P/ASX 200 losing 0.3 percent. Markets had a wild ride last week as the Greek turmoil unfolded; borrowing costs in Spain and Italy spiked after the Oct. 27 bailout agreement was announced, and they rose again last week after Papandreou called for a referendum on the plan.

The composition of the next government remained unclear, although Lucas Papademos, an academic who was once vice president of the European Central Bank, has been mentioned in Greek media in recent days as a possible successor until elections are held Feb. 19. Greece’s finance minister, Evangelos Venizelos, made moves last week to challenge Papandreou’s authority in the Socialist party, although he may be too political a choice to lead the country, analysts said. The Finance Ministry said early Monday that the parties had picked Feb. 19 as the election date.

Whoever inherits the job, even temporarily, will face a tough task pulling the country through the coming months, analysts said. The Greek Parliament will need to approve the terms of the Oct. 27 bailout agreement, which would write off $138 billion in debt held by Greece’s private creditors and commit an additional $180 billion to help the country meet its remaining commitments.

The new leadership will also need to wring more tax revenue from citizens devastated by wage cuts and unemployment, sell state-owned assets at a time when few investors are willing to take risks, and cut the country’s civil service rolls by many thousands. Those steps were already difficult. Now they’re even more so.

“Everybody has upped the stakes,” said Loukas Tsoukalis, head of the Hellenic Foundation for European and Foreign Policy. “We are entering a new phase of the drama.”

Until the power-sharing agreement reached Sunday, the opposition party had hoped for snap elections that would have helped shield it from some of the political heat of the bailout demands. As a coalition partner, it will probably be forced to back tough policies more strongly, lending them more stability than if the Socialists had pushed them through alone. That will bring some measure of reassurance to the international team of inspectors charged with evaluating whether Greece is meeting the targets it agreed to as a condition of receiving the bailout money.

Greece has said it will run out of money by mid-December if it does not receive an $11 billion installment from Europe’s bailout fund. The payment, once supposed to come in September, has been held up because Greece was so far off the mark in meeting its commitments. Analysts say it slipped because its recession was far more severe than anyone predicted and because the stubborn political deadlock in the country made even routine policy changes difficult. Sunday’s agreement is likely to clear the way for the payment.

Papandreou’s imminent resignation brings an end to a two-year tenure that was marked by financial anxiety from the start. When he came to power in a landslide victory in October 2009, he quickly discovered that the country’s deficit was almost double what his predecessors had claimed. Ever since, he has been fighting to get the economic situation under control, resorting to a series of bailout packages that have ballooned as the country’s finances have worsened.

His support steadily slipped as he was forced to push increasingly onerous austerity measures through Parliament. When he announced a referendum last week to give Greeks a choice about the newest bailout plan, it was the final straw for many within his ranks, who felt that the country faced economic catastrophe if they didn’t accept the terms dictated by Europe.

Saturday morning, he narrowly survived a confidence vote, but only after many of his deputies said they wanted him to create a unity government and then step aside.

The son and grandson of Greek prime ministers, Papandreou was seen by many here as less charismatic but more worldly than the famous forebears who shared his name. Born in St. Paul, Minn., he spent his childhood in the United States and attended Amherst College — where he shared a room with the man who would later become his main political antagonist, Samaras — and Harvard University. Many of the protesters who had taken to the streets in recent months to fight the austerity measures told Papandreou to “go home” to America.