Image copyright Getty Images Image caption Ms Rousseff had tried to head off a downgrade with austerity measures

Brazil has lost its investment-grade credit rating following a downgrade by Standard & Poor's to "junk" status.

The US rating agency said mounting political turmoil and the difficulties faced by President Dilma Rousseff's government in tackling growing debt was behind the decision.

Brazil was awarded an investment-grade rating by S&P in April 2008, when the country's economy was on the rise.

However, sliding commodity prices and austerity have created a recession.

Ms Rousseff's left-wing government had imposed austerity measures in a bid to avoid such a downgrade.

S&P downgraded Brazil - Latin America's largest economy - sooner than had been expected.

The move - a major setback for Finance Minister Joaquim Levy's attempts to shore up public finances - is likely to rock the Brazilian stock market on Thursday.

S&P cut Brazil's rating from BBB-minus to BB-plus, which denotes substantial credit risk.

The outlook on the new rating remains negative, which means further downgrades could soon follow.

Analysis: Daniel Gallas, South America business correspondent

Most analysts had forecast Brazil would eventually lose its hard-earned investment grade - as all agencies signalled future downgrades.

But few expected it to come as early as this year. Standard & Poor's was the first to do it; now everyone will be watching how Moody's and Fitch react.

Brazil has faced a string of very bad economic news recently. The current recession is expected to be deeper and longer than expected, with no recovery in sight before 2017.

And then there is politics.

President Dilma Rousseff's main solution - an austerity programme aimed at getting inflation under control - has been under attack from all sides, including allied parties and officials within her own government.

To ordinary Brazilians, who are already suffering with rising unemployment and prices, this news could not have come at a worse time.

Andre Leite, an analyst at TAG Investimento, said that Brazil's rating was now lower than Russia.

"If another rating agency also lowers Brazil, then very probably we're going to see institutional investors obliged to pull their money out," he said.

The government said last month that that the economy was officially in recession.

Image copyright Getty Images Image caption Demonstrators took to the streets of Sao Paulo last month to protest against President Dilma Rousseff and the ruling Workers Party (PT)

S&P said: "The political challenges Brazil faces have continued to mount, weighing on the government's ability and willingness to submit a 2016 budget to Congress" that met economic targets.

"The negative outlook reflects what we believe is a greater than one-in-three likelihood of a further downgrade due to a further deterioration of Brazil's fiscal position," the agency said.

Planning minister Nelson Barbosa said the country would recover its investment-grade status when the economy returned to growth.

He said the government was working on new proposals to balance its accounts and revising programs to tackle the budget deficit.

"Brazil will continue to honour all its obligations," he said.