Moody's Investors Service raised Spain's sovereign debt rating one notch to Baa2 with a "positive" outlook on Friday, praising the country's progress in rebalancing the economy, structural reforms and improved market access.
The move comes as Spain emerges from one of its deepest recessions in decades, struggles with record high unemployment where one on four of the workforce are out of a job and fights to narrow one of the euro zone's widest public sector deficits.
Last Friday, Moody's lifted its outlook on Italy which, like Spain, has suffered a flight in investor confidence amid high public debt and concerns over stability in the euro zone.
Moody's last revised Spain's outlook from "negative" to "stable" in December after cutting its rating to one notch above junk in 2012.
The country first lost its top credit rating at Standard & Poor's in January 2009, followed by Fitch Ratings and Moody's in 2010.
"Not only has the Spanish economy started to growth again in the third quarter of 2013, the growth pattern is also becoming more balanced," the ratings agency said.
"Overall, the rebalancing of the economy has proceeded faster than Moody's had previously expected ... Moody's expects the economic recovery to gather speed in the course of 2014 with domestic demand, particularly business investment, contributing positively to growth."
However, the ratings agency warned that the outlook and rating would face downward pressure if economic improvement or fiscal consolidation stalled.
Spain has one of the highest budget deficits in the euro zone, but has managed to almost halve the size of the gap in the last few years through stringent austerity measures including tax hikes and spending cuts.
Spain is currently rated one notch above junk at Standard & Poor's (BBB-) with a stable outlook, while Fitch has Spain at two notches above junk (BBB) with a stable outlook.
The Spanish government declined to comment on the rating move.