RIO DE JANEIRO (Reuters) - Rio de Janeiro's governor declared a state of financial emergency Friday and requested federal funds to help fulfill obligations for public services during the Olympics that start Aug. 5.

Emergency measures are needed to avoid "a total collapse in public security, health, education, transport and environmental management," a decree in the state's Official Gazette said.

The state's revenue, largely tied to the petroleum industry, slumped in the last two years as global oil prices collapsed.

The announcement followed this week's visit to Rio by Brazil's Interim President Michel Temer, who said the federal government would ensure all obligations are met for a successful Games.

Rio is expecting about 500,000 foreign visitors during the Olympics, which has coincided with Brazil's worst recession since the 1930s and a political crisis that last month led to the suspension of President Dilma Rousseff.

"The state's financial emergency in no way delays the delivery of Olympic projects and the promises assumed by the city of Rio," Mayor Eduardo Paes said on Twitter.

He also underscored that legacy construction projects, with the exception of an 8.79 billion-real expansion of Rio's metro that is expected to be finished just days before the Games open, are the responsibility of the city and that most have been completed.

The local organizing committee for the Games said the state's fiscal situation did not impact its actual running of the Olympics, which relies entirely on private funds.

While the majority of Olympic infrastructure costs have been spread across city, state and federal budgets, with some financing from private companies, the state is responsible for most day-to-day security and health services in Rio.

The financial pinch resulted in a 30-percent cut in the state's security budget - just as Rio has seen a jump in homicides and assaults in recent months, raising concerns about safety ahead of the Olympics.

The state of Rio expects a budget deficit of over 19 billion reais ($5.56 billion) this year as spending planned before oil prices fell outstrips revenue that is tumbling during Brazil's recession.

Rio state's debt has been downgraded several times.

On Wednesday, Fitch Ratings downgraded Rio's debt rating to 'B-' from 'B+', saying the state was suffering "a fast-deteriorating liquidity position."

Since late last year, the state has been forced to delay pension and salary payments and shutter some schools and hospitals, where crucial supplies, including medicines and syringes, are lacking.

Brazil is also facing an outbreak of the Zika virus, which has been linked to the birth defect microcephaly in which babies are born with abnormally small heads frequently associated with developmental issues.

(Reporting by Paulo Prada, Stephen Eisenhammer and Brad Brooks; editing by Richard Chang and Andrew Hay)