RIO DE JANEIRO (Reuters) - Brazil's government disbursed 2.9 billion reais ($895 million) to cover Olympic security spending by the state of Rio de Janeiro, which declared a state of fiscal emergency just weeks ahead of the global sporting event.

A presidential measure published on Thursday in the government's Official Gazette confirmed the emergency loan, an effort to guarantee safety as half a million foreign visitors flock to Rio in the midst of its worst crisis in decades.

Brazil's grinding economic recession is stoking crime and straining public finances, leading to threats of police strikes on eve of the Rio Olympics, which are set to open on Aug. 5.

The first Games to be held in South America were originally planned to showcase Brazil's ascent as a global power, but will be held amid political turmoil, a grinding recession and concern about an outbreak of the Zika virus.

Heightening security fears ahead of the Games, parts of a mutilated body washed up on the sands of Copacabana Beach in Rio de Janeiro on Wednesday, just meters (yards) from where beach volleyball athletes will compete in the Olympics.

The government is also seeking to step up security at Rio's Galeao international airport in the wake of recent attacks in Brussels and Istanbul.

In addition to the public safety scare, there are serious doubts that work will be finished in time for the Games on a metro line connecting downtown Rio to the Olympic Village.

The state government has requested an additional 500 million reais to finish the rail line, but those extra funds were left out of Thursday's loan. The federal government has said that the emergency loan for security spending will free up state funds for the metro.

(Reporting by Pedro Fonseca; Writing by Brad Haynes; Editing by Bernadette Baum)