By Michelle Martin and Andreas Rinke

BERLIN (Reuters) - German Chancellor Angela Merkel said on Wednesday her conservatives had made painful concessions to the Social Democrats (SPD) to secure a coalition deal that should give Europe's powerhouse a new government after months of political paralysis.

In a move that heralds a shift in Germany's euro zone policy, the SPD will take the finance ministry, a post held until recently by conservative Wolfgang Schaeuble, widely loathed in the euro zone's indebted periphery during his eight-year tenure for his rigid focus on fiscal discipline.

SPD leader Martin Schulz, who now needs his party's grass roots to approve the deal in a postal ballot, said this week that the SPD had ensured the coalition would stop "forced austerity" and set up an investment budget for the euro zone.

(For a graphic on Merkel's coalitions click http://tmsnrt.rs/2AdhTpO)

Ceding the crucial finance ministry shows the high price the conservatives had to pay to renew the 'grand coalition' with the SPD that has governed Germany since 2013, and secure Merkel's fourth term in office.

"After so many years in which Wolfgang Schaeuble held the finance ministry, himself becoming an institution, it was hard for many of us that we couldn't hold on to that ministry," Merkel said.

"The question of who gets what job wasn't an easy one," she said, adding that her Christian Democrats (CDU) would take the helm at the economy ministry for the first time in decades.

For the SPD, Schulz said the deal marked a "fundamental change of direction in Europe", adding: "Germany will take an active and leading role in the European Union again."

Bruised by its worst election result in the post-war era, the SPD had planned to revamp itself in opposition and only agreed to the coalition talks reluctantly. Its 464,000 members still have the chance to veto the deal in a postal ballot whose results will be announced on March 4, party sources said.

Story continues

Schulz highlighted policies that the SPD had pushed through, notably reducing the scope for short-term work contracts and increasing student loans and minimum wages for trainees - as demanded by the party's leftist youth wing, which has drummed in new members in the hope that they will vote against the deal.

CDU CHANCELLOR, SPD GOVERNMENT?

Julian Reichelt, editor of Germany's biggest selling paper, Bild, suggested the SPD had got the better end of the deal, tweeting: "This is the first SPD government led by a CDU chancellor."

While the talks have dragged on, Europe's biggest economy has moved into overdrive, offering increased scope for government spending and investment.

Investors and partner countries had been alarmed at Merkel's struggle to assemble a government at a time when Europe faces multiple challenges, including the need for euro zone reform and Britain's looming departure from the EU.

In their 177-page document, the parties laid out plans to develop the euro zone's bailout fund into a full-blown European Monetary Fund anchored in EU law - and therefore outside the direct control of national government - and support budgetary means to shield the euro zone from crises.

They said they would be prepared to pay more into the EU budget. "We want a (European Union) budget for future spending geared toward bringing more benefits for Europe," they wrote, adding that they backed structural reforms championed by French President Emmanuel Macron.

The SPD also gets the high-profile foreign ministry as well as the labor, justice, family and environment portfolios.

Schulz is expected to become foreign minister, despite having previously vowed not to take a cabinet position under Merkel.

The daily Sueddeutsche Zeitung said that Schulz, tarnished by the SPD's poor election result, would quit as party leader, and that parliamentary floor leader Andrea Nahles was ready to take over. Schulz declined to comment.

Hamburg Mayor Olaf Scholz, a down-to-earth, pragmatic politician who was worked well with Merkel in the past, is slated to take over as finance minister, according to sources familiar with the negotiations.

FRAGMENTED PARLIAMENT

Merkel's Christian Democrats (CDU) will get the economy, defense, education and agriculture ministries while their Bavarian allies, the Christian Social Union (CSU), will provide the interior minister, with an added "homeland" portfolio, in the form of Horst Seehofer, who talks tough on migration.

The conservative bloc and the SPD began talks about renewing their alliance only after Merkel failed to agree a coalition last November with two smaller parties in the fragmented parliament.

Support for the two blocs that have dominated German post-war politics has waned even further since the election, and their alliance means the mantle of biggest opposition party now falls to the upstart anti-immigrant, eurosceptic Alliance for Germany (AfD).

After a final negotiating session lasting some 24 hours, the parties ultimately agreed to cap arbitrary fixed-term labor contracts at 18 months, down from 24, and to limit their renewal.

Conservatives balked at the SPD's demand for a complete ban, arguing that firms needed flexibility to be competitive.

On healthcare, the parties agreed to set up a commission to work on a joint fee structure for private and public patients to examine whether it was feasible, a negotiating source said.

Doctors currently tend to get more money for treating private patients, and so often favor them over public patients.

Florian Hense, an economist at Berenberg, said the labor and healthcare reforms, along with more generous pension entitlements, could be expensive. "Germany may pay a price for them with slightly reduced trend growth and a less solidly financed budget after the next recession."

That prospect may be a way off, however. The DIHK Chambers of Industry and Commerce raised its 2018 growth forecast for the German economy to a robust 2.7 percent as consumers with rising wages, secure jobs and low borrowing costs spend more while exports and company investments rebound.

"Companies have never been more upbeat," DIHK said in its latest business survey, adding that German firms are boosting investment plans at an unprecedented pace.

But the BDI industry association said the agreement was "heading towards redistribution rather than shoring up the future".

Alice Weidel, parliamentary leader of the AfD, tweeted: "Things could not get worse for Germany," calling the coalition deal "insane" as it did not contain an upper limit for migration.

(Additional reporting by Holger Hansen, Michael Nienaber, Joseph Nasr, Thorsten Severin, Andrea Shalal and Thomas Escritt in Berlin and Jan Strupczewski in Brussels; Writing by Michelle Martin; Editing by Kevin Liffey)