Labour and Plaid Cymru have agreed in principle to form a historic coalition Welsh Assembly Government.
Plaid AMs have supported plans to share power with First Minister Rhodri Morgan's administration, rather than ousting Labour from office.
Both parties will now have to put the power-sharing document, One Wales, to special conferences on 6 and 7 July.
But the deal ran into immediate trouble when a large number of Welsh Labour MPs "expressed serious concerns" about it.
The One Wales document outlines key pledges including moves towards a full Welsh Parliament, and grants for first-time house-buyers.
The document also includes promises on help for pensioners and students and an end to private sector involvement in the Welsh NHS.
Mr Morgan marked the deal on the steps of the Senedd, the Welsh assembly building in Cardiff Bay, by shaking the hand of Plaid leader Ieuan Wyn Jones.
Mr Morgan said: "I am delighted that we have secured a way forward to provide stable and progressive government for the people of Wales."
It will see Plaid with ministers for the first time, although it is not yet known how many will join the Welsh cabinet.
But on Wednesday night, an "overwhelming majority" of Welsh Labour MPs criticised the deal at a private meeting.
During the discussions, most backbenchers voiced concerns about the agreement, and former party leader Neil Kinnock was said to "absolutely devastating" in attacking it.
The backbenchers are now likely to make their feelings known at Labour's special conference next week.
By agreeing the deal, Plaid's leader has turned down his opportunity to become first minister.
Before plumping for a deal with Labour, Plaid AMs had considered a so-called rainbow coalition with the Lib Dems and the Conservatives to form a Plaid-led assembly government.
But Mr Jones said the Labour deal gave "the best opportunity to provide a stable government over four years".
Plaid came under strong attack from other opposition parties, and Lib Dem assembly leader Mike German said the decision was "condemning Wales to Labour hegemony for decades".
Plaid's national council is likely to have the final say on 7 July on any deal between the two parties, which have traditionally been bitter enemies.
Labour was left with 26 seats after the 3 May election, five short of an absolute majority in the 60-member assembly.
Mr Jones said the weeks since the election had been "very interesting and very difficult" while his party had taken part in discussions on "the best way of forming a stable government for the people of Wales".
He said the two documents provided by possible coalition partners - Labour on the one hand and the Lib Dems and Tories on the other - had contained "excellent policy proposals".
"But eventually we had to make a decision and we have reached a decision," he said.
Mr German said it was "sad day" and that he had already sent a note to Labour leader Rhodri Morgan saying he was prepared to talk to him.
He said: "I'm terribly disappointed that Plaid Cymru haven't been able to follow the course their leader has set out for them.
"This arrangement means that trust in Plaid Cymru by other parties is at its lowest ebb. They have form on this of course, with their last-minute sell-out in the budget discussion.
"The outcome is that they are condemning Wales to Labour hegemony for decades to come because no longer will other parties trust them to form an alternative to Labour government in Wales."
Assembly Conservative leader Nick Bourne said Plaid's decision would disappoint voters who had hoped for a "fresh start" in Welsh politics.
He said: "I have no doubt that the Welsh Conservatives could have worked innovatively with Plaid Cymru and the Liberal Democrats in government.
"The electorate will quite properly hold Plaid to account for the choice they have made to join Labour in government. I believe that Plaid will have to work hard not to be dominated by Labour in this red-green coalition.
"Plaid supporters will judge the success or failure of this arrangement against the now lost opportunity of a Plaid-led [assembly government]."
But Mr Bourne said it was also an important development for his party because it would now become the official opposition.
"Under my leadership Welsh Conservatives will be a constructive opposition," said Mr Bourne.