The leaders who envisioned the Olympics as an opportunity for Brazil to swagger in the international spotlight, including Luiz Inácio Lula da Silva, the former president who has been one of Brazil’s most influential political figures, are mired in scandals.

Mr. da Silva, universally known as Lula, is about to go on trial on charges that he tried to obstruct the investigation of a colossal graft scheme at Petrobras, the national oil company.

Now Mr. da Silva’s handpicked successor, Ms. Rousseff, faces an impeachment trial on claims that she manipulated the budget to conceal mounting economic problems. The scandals have developed against a backdrop of economic wretchedness: The unemployment rate surged to 11.3 percent in July, compared with 6.5 percent at the end of 2014, with companies laying off thousands of workers a day.

Rio de Janeiro, which just a few years ago boasted an economy turbocharged by offshore oil discoveries, is now the epicenter of Brazil’s worst economic crisis in decades. Struggling to pay civil servants and pensioners after squandering a bonanza of oil royalties, the leaders of the state of Rio de Janeiro recently declared a “state of calamity” because of its collapsing public finances.

The days leading to the Olympics have been marked by such a long and varied list of fiascos — including protests over forced evictions and complaints about both thefts and plumbing debacles at the new Olympic Village — that the British sports historian David Goldblatt ranks the preparations here among the worst in Olympic history.

In an effort to bolster security in Rio during the Games, the federal government is deploying thousands of troops to patrol the crime-weary city. But critics say that bringing in soldiers from violence-ravaged cities in northeast Brazil could embolden gang activity there and in other parts of the country.