Alberto Youssef, a convicted money launderer and former bon vivant, sat in a Brazilian jail cell in March of last year, getting ready to tell his lawyers a story. It was about an elaborate bribery scheme involving Petrobras, the government-controlled oil giant. He opened with a dire prediction.  “Guys,” Mr. Youssef said, “if I speak, the republic is going to fall.”  To those lawyers, Tracy Reinaldet and Adriano Bretas, who recently recounted the conversation, this sounded a tad melodramatic. But then Mr. Youssef took a piece of paper and started writing the names of participants in what would soon become known as the Petrobras scandal. Mr. Reinaldet looked at the names and asked, not for the last time that day, “Are you serious?”  “We were shocked,” he recalled, sitting in a conference room in his law office in downtown Curitiba, the capital of the southern state of Paraná, one morning in June. “It was kind of like, in Brazil, we know that corruption is a monster. But we never really see the monster. This was like seeing the monster.”  What Mr. Youssef described to his lawyers, and then to prosecutors after he signed a plea agreement last year, is a fraud that has destabilized the country’s political system, helped tilt the economy into recession and left thousands unemployed. It has all but devastated Brazil’s status as an up-and-comer on the world stage.  The Petrobras scandal would read as pure tragedy were it not filled with a cast of Hollywood-ready characters and their lavish props. The latter include a huge inventory of gifts — Rolex watches, $3,000 bottles of wine, yachts, helicopters and prostitutes. There were also staggering sums of money, most of it flowing through a network of phantom corporations, some of it hand-delivered by an elderly gentleman who flew around the world with bricks of cash, shrink-wrapped and strapped beneath thigh-high socks and a Spanx-like vest.  At the core of the scandal is an old-fashioned kickback scheme. Starting in 2004, according to prosecutors, a small number of top Petrobras officials colluded with a cartel of companies to overcharge the oil company for construction and service work. The cartel would decide which of its member companies would win a contract to, for instance, service an oil rig or build part of a refinery. This fake competition was overseen by Petrobras confederates, who were rewarded with bribes. They kept some of the money but shared much of it with political figures. (The company, while publicly traded, is 51 percent government-owned, and more than a few Petrobras executives owe their jobs to elected officials.)  What has stunned Brazilians isn’t the novelty of this fraud but its epic scale. The first of many national gasps was emitted in December when a former Petrobras employee named Pedro Barusco pledged to give back every cent of his ill-gotten gains — all $100 million.  It was just the beginning. Mr. Barusco told authorities in February that the ruling Workers Party had pocketed up to $200 million over the years, money that was supposedly used to finance political campaigns.  In March, roughly one million Brazilians took to the streets in cities across the country to protest. Much of the furor was directed at President Dilma Rousseff, who was chairwoman of Petrobras during part of the time that the graft ring operated. (She denies any involvement and has not been charged.) But politicians in her party and five other parties have been implicated, so there was plenty of blame to go around.  To date, 117 indictments have been issued, five politicians have been arrested, and criminal cases have been brought against 13 companies. Petrobras officials have pegged the total of all bribes at nearly $3 billion, a figure that makes the scandal at FIFA, world soccer’s governing body, seem like the work of amateurs.  If you don’t live in Brazil, the Petrobras mess has probably registered, to the extent that it has registered at all, as an esoteric swindle perpetrated by people and corporations whose names you don’t recognize. In Brazil, it has convulsed the country with fury and a stinging sense of betrayal.  We asked Brazilian readers on Facebook how the scandal has affected their lives. Hundreds wrote in. This is what they had to say:  In the last decade, Brazil seemed to be on the verge of the kind of sustainable economic boom that its leaders had predicted for years. Ms. Rousseff’s predecessor, Luiz Inácio Lula da Silva, had boldly predicted Brazil would rise to greatness in the 21st century, a forecast that seemed entirely plausible when, in 2010, the country’s economy expanded at the rate of 7.5 percent, its greatest performance in 24 years. Brazil, along with China, India and Russia, was regarded as among the world’s most promising emerging markets.  Oil was central to Brazil’s strategy, and that gave Petrobras a leading role in the nation’s growing influence — and pride of place. At one time it was the sixth-largest company in the world by market capitalization and accounted for roughly 10 percent of Brazil’s gross domestic product. For perspective, Apple, which has twice Petrobras’s peak market cap, represents 0.5 percent of the United States’ gross domestic product.  The company has lost more than half its value in the last year, about $70 billion in market cap. Part of that stems from the worldwide decline in oil prices, but none of the company’s rivals have been punished as severely. That plunge has had repercussions for investors worldwide. Petrobras had been a favorite investment for big emerging-market bond funds sold to United States investors, for instance.  In Brazil, Petrobras’s plunge is so cataclysmic, according to analysts, that it is a major reason the economy is expected to contract by more than one percentage point this year. Unemployment is up, and Standard & Poor’s has cut the nation’s long-term debt rating to one notch above junk status.  All of this has provoked something that transcends outrage. Brazilians are in the midst of an identity crisis. Much of Brazil’s recently acquired cachet looks as if it was the product of fraud, and for an added touch of humiliation, a fraud cooked up at a company long regarded as an emblem of Brazil’s success and aspirations.  “I’ve never seen my countrymen so angry,” said Maurício Santoro, a political science professor at Rio de Janeiro State University. “We have this sense that the dream is over.”  Brazilians have a saying when the rich and powerful are arrested: “It always ends with a pizza party.” The words, invariably uttered with disgust and resignation, are meant to suggest that the justice system is rigged in favor of the elites. The accused are said to avoid prison and then celebrate by ordering pizza.  If any good has come from the Petrobras debacle it is the flickering sense that this time could be different. Part of the reason is the work of Judge Sérgio Moro, who is overseeing the investigation, officially known as Operação Lava Jato, or Operation Carwash. In Brazil, judges have wide latitude to define both the direction and scope of criminal inquiries, and Judge Moro’s willingness to pursue even the eminent and influential has made him a folk hero. During a recent visit to the courthouse where he presides in Curitiba, ribbons of yellow and green, the national colors, were tied around trees, quiet expressions of solidarity and support.  Another source of public optimism can be found on the eighth floor of an office building a few miles away, in rooms that could pass for a low-budget telemarketing operation. This is home to the team of nine prosecutors working on Lava Jato, as everyone here calls it.  The lead prosecutor, Deltan Dallagnol, is 35 and has a degree from Harvard Law School. A prodigy of sorts, he became a prosecutor at 22, and joined Brazil’s anticorruption task force three years later.  The prosecutors’ investigation has its origins 670 miles north of Curitiba, in Brasília, the nation’s capital, courtesy of a peculiar stroke of luck.  “You needed a lot of improbable factors aligned for this case to begin,” Mr. Dallagnol said, sitting at a conference table one afternoon. “It was like the gods giving us a window of opportunity.”  In 2012, the federal police were conducting a money-laundering investigation, which included surveillance of the owner of the Tower Gas Station. (This undistinguished institution once housed a carwash, since closed, which gave the investigation its name.) An officer on a wiretapped conversation realized that he was listening to Alberto Youssef.  “Youssef had been a pilot for many years, and the cop was once an air traffic controller,” said Mr. Reinaldet, Mr. Youssef’s lawyer. “And the cop, he said to himself, ‘I know this guy.’ Pretty soon, they were tapping Youssef’s cellphone.”  More than a few federal officers would have recognized Mr. Youssef’s voice. By then, he had been arrested at least five times, in connection with crimes as varied as smuggling electronics and embezzlement. But amazingly, Mr. Youssef had spent little more than 15 months in prison. He kept signing plea agreements, spouting information and names in exchange for reduced sentences.  You might think a reputation as a serial informant would eventually impinge on his criminal opportunities, but he apparently has enough charisma and connections to disarm just about anyone. That includes people he has already helped land in prison. When a lawmaker at a Brazilian congressional hearing in May asked Nelma Kodama, who had been sentenced to 18 years for her role in Lava Jato, about her relationship with Mr. Youssef, she broke out into “Beloved Lover,” a popular 1970s-era love song.  Mr. Youssef was raised in straitened circumstances in Londrina, a town in Paraná, and as a teenager he helped his mother at a food concession at a local airport. It was there that he was befriended by José Janene, a businessman, pilot and future member of Congress.  After earning his license to fly, Mr. Youssef smuggled expensive electronics into Brazil from Paraguay, where taxes were much lower. He graduated to the higher-margin business of money laundering. In late 2006, he became part of the Petrobras bribery scheme. He later told Judge Moro and prosecutors that his involvement had been at the invitation of Mr. Janene, who died in 2010.  The big break in the Petrobras case came when surveillance discovered an email from Mr. Youssef describing a Range Rover purchased for a Petrobras executive named Paulo Roberto Costa. From 2004 to 2012, Mr. Costa was Petrobras’s director of supply, a job that put him in the ideal position to approve major contracts. The four-wheeled gift led, eventually, to a warrant to search Mr. Costa’s office and to his arrest. He became the first Lava Jato insider to talk.  Soon after, Mr. Youssef decided to yet again turn state’s evidence. With two leading-role cooperators, prosecutors quickly realized, as Mr. Dallagnol put it, “we had a case that was 100 times bigger” than their original investigation.  As one of the world’s largest oil companies, Petrobras spends more than $20 billion a year expanding its capacity, building new plants and servicing facilities. That means huge sums of money are spent on a variety of work, much of it subcontracted to companies that have long fought one another for the business.  But about a decade ago, according to prosecutors, these companies stopped competing and started to collaborate. They formed a cartel and decided, in advance, which of them would win a particular deal. A charade competition was orchestrated, and the anointed winner could charge vastly more than it would in a free market.  The cartel called itself “the club,” according to depositions and documents submitted to the court. It had 16 members by 2006, including blue-chip behemoths like Odebrecht and Camargo Corrêa. They often met in the offices of a São Paulo-based engineering company called UTC Engenharia, occasionally summoned via a text message from UTC’s owner, Ricardo Pessoa. (Mr. Pessoa has since become a cooperating witness and is under house arrest.)  A document obtained by prosecutors laid out what it called the “rules of the game.” The trumped-up bidding process was labeled a “sports tournament,” with an assortment of rounds and a “trophy.” There was a no-sore-loser codicil, too: “The teams that participate in a round should honor the rules that have been agreed on, even when they are not the winner.”  Club members were soon landing all major Petrobras contracts, with an assist from Petrobras insiders like Mr. Costa and Jorge Zelada, the director of the company’s international division, who was arrested in July. From 1 to 5 percent of the value of a given contract was diverted to those on the receiving end of the scheme, a group that included 50 politicians from six parties, according to prosecutors.  Money from cartel members took a circuitous route to politicians’ pockets, passing through ghost corporations whose owners made bribes look like consulting fees. They kept a small percentage for their efforts and then passed funds on to one of a handful of doleiros — the word translates, imperfectly, as money changers — who shuffled funds in the scheme. The doleiros, among them Mr. Youssef, would keep a cut, spreading the bulk around to politicians and accomplices.  Enter Rafael Lopez, the money mule. He took hundreds of trips, according to his lawyer, André Pontarolli, with portable fortunes cinched under his clothing. (“Five hundred thousand euros was his record,” Mr. Pontarolli said.) He wore the sort of socks favored by soccer players, and, when the haul was especially large, an orthopedic undershirt.  Mr. Youssef became a public face of Lava Jato, helping move $444 million to foreign bank accounts in more than 3,500 transactions from 2011 to 2014 alone. This yielded enough cash for Mr. Youssef to acquire luxury cars, homes and a number of hotels. But the work was tedious, stressful and infuriating. Much of his time was spent nudging executives for bribes that were late, or placating politicians asking variations of “Where’s my money?” It was a nightmare of logistics and diplomacy in a realm of big egos and outstretched palms.  In an obscenity-filled conversation that the police secretly taped in 2013, Mr. Youssef vented his frustrations to a construction company executive: “No one here knows how to do the math!”  The land near Itaboraí, an hour’s drive northeast of Rio de Janeiro, was once known for its orange groves, but it became a boomtown when Petrobras broke ground on an immense refinery and petrochemical plant called Comperj six years ago.  Today, Itaboraí looks as if it was hit with the magic wand of prosperity by a wizard who had second thoughts. New office buildings and high-end hotels sit empty and covered in dirt. There’s a nearly barren field where a federal technical school was supposed to open. Billboards along the winding road to Comperj, which is a mile or so outside town, are blank, except for an ad for a company that removes industrial equipment.  No one can say exactly how much the kickback scheme cost Petrobras itself — the prosecutors assume that if companies were willing to pay $2 billion in bribes, it had to be at least that much — but the broader losses to the country can be seen in places like Itaboraí.  Some 20,000 workers flocked to the area when Petrobras started building Comperj, hoping to land jobs for a project originally estimated to cost $6.1 billion, according to a report in O Globo that cited internal Petrobras documents. (A state audit later put the figure closer to $50 billion, citing delays, cost overruns and reckless management.) But as Lava Jato came to light, Petrobras ceased construction.  Thousands of men are now jobless. One of them, Jucelio Nascimento, had just left an employment agency one morning in June and was leaning against a nearby wall.  “I wanted to look the guy in the eye and ask, ‘Is there work?’ ” he said, through a translator. “Because I’m tired of waiting.”  Clad in a red-and-white soccer jersey, Mr. Nascimento said he moved here last summer and found work doing maintenance on pipes, earning 2,600 reais a month — then worth about $1,150, a better-than-decent wage in this country. But Lava Jato happened, and one day his supervisor showed up to say everyone was laid off, the supervisor included. Since then, to save money, Mr. Nascimento has spent most nights in his car.  Comperj is just one failure. There have been many other halted projects and mass layoffs. Four construction companies have gone bankrupt. But not all of Lava Jato’s reckonings are so grim. Prosecutors and the federal police have been seizing cash and assets, including fine art. Because storing expensive paintings and photographs is not a law enforcement specialty, the entire haul has been handed over to the Oscar Niemeyer Museum in Curitiba. Since April, the works, mostly by Latin American masters such as Heitor dos Prazeres and Vik Muniz, have starred in an exhibit called “Art in the Custody of the Museum.”  Petrobras officials who illegally enriched themselves were, of course, bounced from the company and into the justice system. There is also a new C.E.O., who took over in February, and many new faces in upper echelons, part of a campaign to prove that Petrobras understands the gravity of this crisis and will ensure it never happens again.  The job of changing the company culture has fallen to João Elek, Petrobras’s newly appointed head of compliance. He says that for years, nobody questioned top-tier managers, even if they approved transactions that seemed odd. A more robust whistle-blower program is also being established with an outside firm.  “If someone has a suspicion that their boss isn’t capable, that’s enough for an investigation,” Mr. Elek said. “The boss has good relations with a politician, with God, with the pope — we don’t care.”  There was no mention, however, of efforts to alter the decades-long connection between the political class and the corner offices of Petrobras. The company employs many highly respected engineers and managers, but for years, critics argue, it has also been a place for politicians to park friends and allies. (Paulo Roberto Costa was appointed to his job, for instance, by members of the Progressive Party.) Proceeds from Lava Jato were spent on campaigns, according to court documents; by officials of the Workers Party, to which President Rousseff belongs; and other parties in her coalition.  “This crisis goes to the heart of Brazilian state capitalism, the blurring of lines between state economic policies and state benefactors,” said Matthew M. Taylor of the American University School of International Service. “What is being demonstrated is the cost of the intertwined relationship between business and the state, and the types of corruption that can lead to.”  It’s a relationship that goes back hundreds of years. When Mr. Costa decided last year that he needed to cut a deal with prosecutors, he opened his first interview with a bit of historical context.  “He sat at a table,” recalled Mr. Dallagnol, the prosecutor, “and he said, ‘What I’m going to tell you is a story that began in 1808, when the royal family of Portugal came to Brazil and they were guests in the house of a slave trafficker.’ ” Mr. Costa was talking about the man who would become King João VI, who fled Europe after Napoleon’s troops invaded.  “His point was, all the interchange between the public and private worlds in Brazil began a long time ago,” Mr. Dallagnol said. “At the time I was thinking, tell me something I don’t know.”  Brazil’s enduring corruption has put it in 69th place on a list by Transparency International of 175 countries ranked by how corrupt their public sectors appear to be. The problem provokes widespread repugnance, but polls have also found that 70 percent of Brazilian citizens would take illegal benefits if they were in a public job and had the chance.  Mr. Dallagnol frames this paradox in the starkest possible terms: “If you look at studies of corruption, you see that it actually kills. With money we lose here, we could spend three times as much on public health. We could multiply the amount spent on education. We could lift 10 million Brazilians out of poverty.”  There is evidence that the problem is systemic. Yet another bribery boondoggle, this one involving Eletrobras, the country’s largest power utility company, has recently emerged. Once again, prosecutors are charging that insiders took cash to award padded construction contracts, this time to build a $4.4 billion nuclear power plant. Many in Brazil believe that kickbacks have become standard operating procedure in government-controlled enterprises.  It takes surprisingly few insiders to pull off such schemes. Judge Moro and the prosecutors have officially described Petrobras as a victim, citing its immense financial losses and the small number of conspirators, a point Mr. Elek was quick to reiterate. “There are 86,000 people in this company,” he said, “and an insignificant percent of them caused this problem.”  But others, including class-action lawyers in New York, contend that enough Petrobras leaders were involved to hold the company liable. A lawsuit seeking unspecified damages for shareholder losses has been filed in the Southern District of New York on behalf of a British pension fund; the city of Providence, R.I.; and others. Petrobras says the suit is without merit. In July, Judge Jed Rakoff rejected Petrobras’s motion to dismiss the case.  “For Petrobras to say, ‘We’re the victims,’ when their executives were perpetrating this scheme suggests that they haven’t learned their lesson,” said Jeremy A. Lieberman of the Pomerantz law firm, which has been appointed lead counsel in the case. “This is not just an incident of a few rotten apples on an otherwise pristine tree.”  For all of its malign effects, Lava Jato has underscored that Brazil has a robust and independent group of federal police officers, judges and prosecutors, a rarity in nations plagued by corruption. Last month, for instance, the police searched the home of Fernando Collor, a former president and current senator, leaving with a Ferrari, a Lamborghini and a Porsche. (Mr. Collor has not been charged and denies involvement in Lava Jato.)  Mr. Dallagnol and another prosecutor flew to Washington a few months ago to visit officials in the Justice Department, hoping to interest the United States in lending a hand. He says that he and his team could, if unhindered, investigate Lava Jato for years.  Still, does he expect this case to end with a pizza party? You might expect Mr. Dallagnol to scoff at the prospect, but he knows the system too well.  “It’s hard to predict,” he said. “Statistically, when you have cases against the rich and powerful, things tend to end with pizza. We have no illusions. No aspirations to be superheroes. We are only a group of guys determined to do our best.”  One person who will be celebrating before too long is Alberto Youssef. Stress and jail have turned his hair gray, slimmed him down by 40 pounds and landed him last year in the hospital with a heart attack. His wife divorced him and he is said to be destitute. His days as a nexus of cash and gifts are over.  But Judge Moro determined that his assistance had been so helpful that he was given the minimum sentence allowed in his plea agreement. With the time he has already served, he will be free by the beginning of 2017.  Catherine Osborn contributed reporting from Rio de Janeiro.  A version of this article appears in print on August 9, 2015, on page BU1 of the New York edition with the headline: Brazil’s Great Oil Swindle. Order Reprints| Today's Paper|Subscribe
A far-reaching investigation into corruption at the state oil company has destabilized the government, damaged the economy and wounded national pride.