She was born 58 years ago, about the time Petrobras was conceived to reduce Brazil’s dependence on foreign oil. In the 1950s, her parents moved from the interior of the neighboring state of Minas Gerais to Rio, where they lived in Morro do Adeus, a poor hillside area that now is part of Complexo do Alemão, a collection of favelas occupied by Brazilian security forces.

As an 8-year-old, she contributed to her family’s meager income by working as a trash recycler, collecting discarded cans and paper. She said she had also earned money by writing and reading letters for her neighbors, a family of immigrants from Portugal.

After attending public schools here, she became an intern at Petrobras while studying chemical engineering at the Federal Fluminense University. Then she was lured away into postgraduate studies in nuclear engineering, at a time when Brazil was developing its nuclear energy capacity. But she balked at the prospect of spending five years in Germany to delve further into the field, so she returned to Petrobras. Once back at the company, she never left, rising through a series of management posts and obtaining an M.B.A. at Fundação Getúlio Vargas, an elite Brazilian university.

In 1998, while working for a Petrobras unit involved in a pipeline to import natural gas from Bolivia, she met Ms. Rousseff, then an obscure energy official in Rio Grande do Sul, a southern Brazilian state. Ms. Foster, a supporter of the leftist Workers Party, which has been in power in Brazil since 2002, saw eye-to-eye ideologically with Ms. Rousseff, a Marxist guerrilla in her youth; they both are now committed to welcoming foreign investment in Brazil’s oil industry and exposing Petrobras to market forces.

When the former president, Mr. da Silva, appointed Ms. Rousseff to his cabinet as Brazil’s energy minister, she named Ms. Foster as one of her top aides in Brasília, the capital. After serving in that position for two years, she chose to return to more hands-on responsibilities at Petrobras. “My business,” she said, “is oil and gas.”

Shares in Petrobras jumped nearly 4 percent on the day in January she was named as chief executive, replacing the economist José Sergio Gabrielli. But important challenges await her.

Already, she is facing the scrutiny of Brazil’s media, arguably Latin America’s most aggressive in questioning the power structures at large companies like Petrobras. The newspaper Folha de São Paulo reported in 2010 that a company controlled by Ms. Foster’s husband, Colin Foster, a Briton who has long lived in Brazil, had won numerous contracts since 2007 worth hundreds of thousands of dollars to supply Petrobras with electronic equipment.