Bulgaria's Socialist Party (BSP) has signed a coalition deal with the outgoing prime minister's centre-right party, ending seven weeks of deadlock.
Mr Stanishev has spent weeks trying to form a government
Ex-prime minister Simeon Saxe-Coburg, who was Bulgaria's child king during World War II, said BSP leader Sergei Stanishev would head the coalition.
Mr Saxe-Coburg's National Movement (NMS) was beaten in the June elections by the BSP, which got 31% of the vote.
A liberal, mainly ethnic-Turkish party will also be in the new government.
The Bulgarian parliament reconvenes on Tuesday and is expected to pass a vote of confidence in the new coalition.
Bulgaria is due to become a member of the European Union in 2007, but must carry out a series of reforms to meet the entry requirements.
Some analysts say the delay in forming a government has harmed Bulgaria's prospects of joining the EU on schedule.
The NMS came second in the election with just under 20% of the vote, ahead of the mainly ethnic Turkish Movement for Rights and Freedoms (MRF) with 12.7%.
A radical nationalist group called Ataka won 8% - enough to enter parliament. It challenges Bulgaria's tentative efforts to integrate its Turkish and Roma (Gypsy) minorities.
Pressure for reforms
Mr Stanishev said the coalition's priorities would be "European integration, social responsibility and economic growth".
And Mr Saxe-Coburg said the deal "sent a very important signal to Brussels".
"It is important for Brussels to see that there is continuity in Bulgaria," he added.
The new coalition will have a comfortable majority in parliament, backed by 169 of the 240 deputies, correspondents say.
The BBC's South-East Europe analyst Gabriel Partos says the coalition parties are aware of the need to focus on legal reforms, including a new penal code, to meet the EU entry conditions on time.
Despite achieving steady economic growth, Mr Saxe-Coburg's government lost support because of continuing widespread corruption and poverty, he says.
Our correspondent adds that stability is likely to be helped by two nominations to the new coalition:
- Plamen Oresharski, a non-party figure chosen to be finance minister;
- Meglena Kuneva, chosen to stay on as European affairs minister.