
This is the moment riot police unleashed tear gas at drug addicts in Brazil - as millions across the country prepared to celebrate Carnival 2017.

The glittering annual party, which attracts more than a million tourists a year, is kicking off across Brazil against a grim background of recession and crime.

A cocktail of crises has hit the country since South America's first Olympic Games six months ago with at least 37 cities cancelling their carnivals for lack of funds or security.

Pictures show police in protective outfits clashing with drug users in an area of Sao Paulo known as 'crackland'. In the same week, thousands of the city's residents dressed up for spectacular carnival parades and parties.

Under fire: Pictures show police in protective outfits clashing with drug dealers in an area of Sao Paulo known as 'crackland'

Pictures captured the moment riot police clashed with rival drug gangs in Brazil - as millions across the country prepared to celebrate Carnival 2017

Contrast: In the same week, thousands of Sao Paulo's residents dressed up for spectacular carnival parades and parties

The glittering annual party, which attracts more than a million tourists a year, is kicking off across Brazil against a grim background of recession and crime

Officers resorted to tear gas and rubber bullets to quell a confrontation in what is an open-air crack cocaine market in the heart of city, where the drug is purchased and smoked in plain sight, day or night.

Police were attacked with rocks and pieces of wood during the two-hour clash in which nobody was arrested.

As Carnival prepares to enter full swing, the country's economy is crumbling, public coffers are empty and street protests are turning violent.

In much of Espiritu Santo state, which borders Rio de Janeiro, carnival has been scratched, Brazilian media report, because of a bloody episode this month when police went on strike and 140 murders were committed in the space of a week.

Rio, home to the country's and arguably the world's most important carnival, has also been on edge.

Violent confrontations have taken place since the start of the year between riot police and protesters against austerity measures meant to rescue the nearly bankrupt state.

A young girl cries after inhaling tear gas fired by the police as they clash with drug users in the region known as 'Cracolandia'

Police were attacked with rocks and pieces of wood during the two-hour clash in which nobody was arrested

Officers resorted to tear gas and rubber bullets to quell a confrontation in what is an open-air crack cocaine market in the heart of city, where the drug is purchased and smoked in plain sight, day or night

Military tactical police officers advance on suspected drug users in the region earlier this week

Earlier this month relatives of street cops tried to blockade stations in protest of late payment of salaries - raising fears that law and order would weaken further in a city buffeted by rising crime. Detectives are already on strike over late salaries.

In the run-up to the carnival, some 9,000 soldiers and marines were deployed in Rio streets, the camouflaged, rifle-toting men standing out amid the bathers of Copacabana and other popular sites.

Despite the state governor's plea for the troops to stay, they were ordered to withdraw as of Wednesday.

Given the tension in Brazil, it's no surprise that politics is not far from the partying.

Rio carnival goers were surprised to learn that their newly elected mayor, who is also an evangelist bishop, is not expected to attend.

He has already confirmed that he will break with tradition and not personally hand the keys to Rei Momo, apparently out of distaste for the wild excesses of the city's favorite public event.

As Carnival prepares to enter full swing, the country's economy is crumbling, public coffers are empty and street protests are turning violent

This woman pulled on fancy dress glasses during the colourful Carnival of Banknotes in Sao Paulo

A cocktail of crises has hit the country since South America's first Olympic Games six months ago with at least 37 cities cancelling their carnivals for lack of funds or security

The parades themselves have an unusually political slant this year.

One samba school will recreate an embezzlement scandal under France's King Louis XIV - a theme with distinctly current overtones in corruption-riddled Brazil.

Another school's parade will depict deforestation and destruction of indigenous lands, infuriating the country's powerful agribusiness lobby.

Yet even with all this rancor, the city is primed for fun.

Revellers celebrate at the 'LED is My Light' street party in Rio in the early morning hours of Friday

The party-goers took over an underpass and drank and danced in a see of LED lights

Cariocas, as Rio residents are called, have been partying hard in informal street 'blocos' for several weeks

Revelers walk past men sleeping on the pavement as the city bursts with the light of street celebrations

'The carnival looks like a party and it is one, but it's much more than that,' said writer Gregorio Duvivier, a prominent carnival participant.

'It often serves to help us put aside our problems for a few days.... I think that it's even greater in time of crisis, because it's even more needed.'

For Rio, carnival starts Friday and it couldn't come soon enough for a city reeling from a series of set backs.

Patients from the Nise da Silveira Mental Health Institute dance during a carnival parade coined, in Portuguese: 'Loucura Suburbana', or Suburban Madness in Rio on Thursday

A patient from the institute with an octopus on his head. Patients, their relatives and Nise da Silveira staff were all involved in the parade

Tourists and Cariocas gather at a pre-Carnival bloco, or street party, on Thursday night

Excited party-goers play musical instruments at a street party. The official Rio Carnival begins with the handing over of the city keys to the carnival king

The annual bash kicks off officially with the handing over of the symbolic city keys to Rei Momo, the carnival king.

Already the country was shutting down: streets were beginning to empty, most businesses prepared to close until next Thursday, and even the usually raucous chamber of Congress in the capital Brasilia was deserted.

Cariocas, as Rio residents are called, have been partying hard in informal street 'blocos' for several weeks, but now the serious fun begins with rival samba parades in the Sambodromo stadium.

People in a crowd fly the Pride flag during celebrations in Sao Paolo on Sunday

The first parades start in Rio on Friday. In the run-up to the event, some 9,000 soldiers and marines were deployed in the streets

Some of the parades will have political slants this year with some samba schools choosing to allude to corruption and deforestation in their performances

The first parades start Friday, warming up for the elite 'special group' samba schools like Mangueira and Beija Flor who compete all through Sunday and Monday nights.

Watched by 70,000 people in the Sambodromo, the parades are intense, heart-pounding affairs where as many as 3,000 performers at a time dance and sing in outrageously over-the-top costumes.

Their goal will be winning the coveted top prize awarded on Ash Wednesday - the start of Lent in this mostly Catholic country.