By Alonso Soto and Reese Ewing

BRASILIA (Reuters) - Brazil's federal government reached a deal on Tuesday to help cash-strapped states with their fiscal woes in exchange for support from governors on deeper structural reforms including pension reform and the capping of public employee salaries.

Finance Minister Henrique Meirelles told reporters after meeting President Michel Temer and governors in Brasilia that federal and state governments have agreed to a "grand national accord to balance public accounts."

Meirelles said the government would share proceeds from an amnesty program for the repatriation of undeclared foreign assets to help states with their immediate budget crises. He said proceeds from an expected second phase of the program would be negotiated with the states.

In return for a share of the repatriation revenue, governors pledged to rein in state spending growth to no more than inflation in the previous year, in a replica of the proposal in Congress to limit federal spending growth.

States also agreed to cap salaries for public sector workers and put a freeze on new hires for two years.

Down the road, governors signed on to support and carry out reform of Brazil's extremely generous pension system, Meirelles said, which is likely to be more challenging for government than the immediate proposal to bring real spending growth to zero.

The fine print of the agreement with the states has yet to be hammered out, Meirelles said. He said there would be revenue growth "for everyone" as economic confidence returned.

Brazil is mired in its worst economic downturn in eight decades and a return to growth has so far been elusive.

Rio de Janeiro state is facing its most acute budget crises in memory. Brazil's most well known state has been unable to tap debt markets and is thus struggling to pay its teachers, firemen, doctors and keep up on all number of public services.

Violent protests against an austerity package that Governor Luiz Fernando Pezao attempted to push through have rocked Rio's state assembly house this week. The state hosted the Olympics barely three months ago. Members of the government are concerned that if spending limits and pension reforms are not passed quickly by Congress, demonstrations could spread to other states and hurt the popularity and political capital of the president.

Rio Grande do Sul earlier on Tuesday declared a state of financial calamity after submitting an austerity package to its local assembly to slash payrolls and sell state-run companies to cover its fiscal deficit.

(Reporting by Alonso Soto and Reese Ewing; additional reporting by Lisandra Paraguassu; Editing by Lisa Shumaker and Grant McCool)