Standard & Poor's lowered Spain's long-term credit rating by two notches on Thursday, saying the country's budget problems are likely to get worse because of the weak economy.

S&P reduced Spain's long-term sovereign credit rating to "BBB+" from "A." The agency also lowered Spain's short-term rating and assigned a negative outlook, which suggests the possibility of another downgrade in the near future.

Spain's credit rating is still in investment grade, three notches above junk status. Nonetheless, the lower rating could increase the nation's borrowing costs because investors will likely demand higher interest rates to compensate for the greater risk implied by the downgrade.

But it is nowhere near Greece, which was downgraded to default by the three major rating agencies after its private creditors were forced to take the biggest debt writedown in history. The agencies — S&P, Moody's and Fitch — are expected to raise Greece's rating after it completed this week a huge bond exchange designed to more than halve its privately held debt.

S&P's downgrade of Spain, announced after the close of markets in the U.S., was not a total surprise. Moody's, cut the country's rating two notches in February due to the country's difficult fiscal outlook.

S&P cited the risk that Spain's government debt will expand as the contracting economy exacerbates the nation's budget woes. The Spanish central bank confirmed this week that Spain is in recession for the second time in three years. A jobless rate of nearly 23 percent is expected to rise.

The ratings agency also noted the "increasing likelihood" that the Spanish government will need to provide further help for the banking sector.

To go along with the credit downgrade, S&P lowered its forecast for Spain's economic outlook. The agency said it expects the economy to contract by 1.5 percent this year and 0.5 percent in 2013. Its previous outlook had growth of 0.3 percent in 2012 and 1 percent in 2013.

Spain's new conservative government has forecast that the economy will contract 1.7 percent this year.

The drags on economic growth include declining disposable incomes, reduction in private borrowing, implementation of the government's fiscal plan, and uncertain demand in key trading partners, S&P said.

The agency said Spain's economy is "rebalancing," and the government's moves should help.

The government of Prime Minister Mariano Rajoy has pushed through deficit-reduction steps including labor market and financial sector measures.

S&P praised the government's labor-market reforms, which it said would slow the pace of job-cutting and eventually help improve the employment picture. But it warned that the measures won't create net new jobs in the near term.

"As a consequence, the already high unemployment rate — especially among the young — will likely worsen until a sustainable recovery sets in," S&P said.

Spain is digging out from the 2008 collapse of a property bubble that had fueled nearly a decade of growth.

S&P had harsh words for Europe's handling of the debt crisis, which it said "continues to lack effectiveness." It said that Spain's situation could deteriorate further unless Europe takes steps to bolster investor confidence and stabilize capital flows with the rest of the world. It suggested more pooling of resources and obligations and policies to better coordinate wages among European countries.