* S&P ends years of ratings downgrades for Italy
* Says improving economy, stronger banks a help
* Main government party hails upgrade (Adds backgrounds, Renzi's reaction)
ROME, Oct 27 (Reuters) - Credit ratings agency Standard & Poor's unexpectedly raised its sovereign rating for Italy to BBB on Friday, the first such increase by S&P for at least three decades.
S&P said the rise from a previously given BBB- was justified because of Italy's strengthening economic outlook, growing investment, a steady uptick in employment and improvements in the debt-laden banking sector.
It maintained its outlook as "stable".
"After years, finally, S&P has raised Italy's rating. The work is paying off," former prime minister Matteo Renzi, who heads the ruling Democratic Party (PD), said on Twitter.
S&P's move comes as Italy's political parties are gearing up for national elections that are widely expected in March 2018, with Renzi's PD party trailing in the polls behind the anti-establishment 5-Star Movement and a resurgent centre-right group.
S&P last reviewed its Italy outlook in May.
Since then a modest economic recovery has been seen and last month Prime Minister Paolo Gentiloni's government raised this year's growth forecast to 1.5 percent, from a 1.1 percent estimate made in April.
It raised next year's forecast to 1.5 percent from 1.0 percent. Earlier this week, statistics institute ISTAT said morale among Italian businesses and consumers had hit multi-year highs in October, pointing to a strengthening economy.
S&P predicted growth of 1.4 percent this year and 1.3 percent in 2018-2019.
"We are upgrading Italy because of its improved economic growth prospects, supported by rising investment and steady employment growth as well as by an expansionary monetary policy," S&P said.
"In this context, the upgrade also reflects subsiding risks in the banking sector for the economic outlook, and expected further budgetary consolidation over our forecast horizon."
Italy's banks were ravaged by a prolonged economic downturn, leaving the sector groaning under hundreds of billions of euros of bad loans. The government had to intervene to save a number of lenders, while other banks looked to shift risky assets off their balance sheets.
The Bank of Italy said earlier this month that insolvent loans held by Italian banks fell to their lowest level in August since July 2014.
While raising its growth forecasts last month, the government also increased its target for next year's budget deficit to 1.6 percent of gross domestic product, from 1.2 percent previously.
The public debt, the highest in the euro zone after Greece's, was targeted to fall slightly to 130 percent of GDP next year from a targeted 131.6 percent this year.
"The ratings are constrained by Italy's extremely high fiscal debt burden," S&P said, adding that political uncertainty also weighed, with opinion polls suggesting the next election will end in a hung parliament.
S&P has relentlessly downgraded the euro zone's third largest economy since 1988, when the credit rating stood at AA+. The BBB- rating, just one notch above junk status, had been in place since Dec. 5, 2014.
Both Moody's and Fitch upgraded Italy's rating in 2002, only to have to subsequently lower it later. Moody's confirmed its Baa2 rating for Italy earlier this month, while Fitch cut the country's rating to BBB from BBB+ in April. Source text: (http://bit.ly/2yPv7aZ) (Reporting by Crispian Balmer and Valentina Za; editing by Andrew Roche)