(Adds data, analyst comment, background)
BRASILIA May 22 (Reuters) - President Dilma Rousseff's main rivals have cut her lead ahead of Brazil's elections in October, though she is still favored to win re-election if the race goes to a second round, according to a poll published on Thursday.
As the campaign shifts gears and undecided voters begin to pick candidates, Rousseff's opponents have gained more traction than the president from growing media exposure, making a run-off more likely.
Hurt by high inflation and a scandal involving state-run oil company Petroleo Brasileiro SA, left-of-center Rousseff has managed to stem a decline in popularity with steps such as an increase in poverty relief on May 1.
Voter support for Rousseff recovered to 40 percent in May from 37 percent in a previous poll in April, the local IBOPE polling firm said.
"The poll shows that Rousseff's hemorrhaging in April has stabilized," said Joao Augusto Castro Neves, a political analyst with the Eurasia consultancy in Washington.
But her main rival, Aécio Neves of the centrist PSDB party, rose to 20 percent from 14 percent in April, while Eduardo Campos, the candidate of the Brazilian Socialist Party, advanced to 11 percent from 6 percent the month before.
Added together, Neves, Campos and other possible candidates now have 36 percent of eligible votes, reducing the gap with Rousseff to just four percentage points, from 13 points a month earlier. Rousseff needs to win more votes than all other candidates put together to avoid a run-off.
Neves and Campos have reduced their negatives, but Rousseff has not, with 33 percent of voters still rejecting her.
The election campaign heated up last week with a combative video by Rousseff's ruling Workers' Party that focused on how life had improved for Brazil's poor since it came to power in 2002, warning voters those gains could be lost.
While campaigning will not start officially until after the soccer World Cup ends in mid-July, little-known opposition candidates have gained ground by stepping up public appearances and media interviews.
Undecided voters have dropped to 10 percent from 13 percent a month earlier, and the number of people who said they would not vote on Oct. 5 has fallen from 24 percent to 14 percent, the IBOPE poll said.
"Voters are beginning to pay more attention to the election and preferences are starting to consolidate," said Castro Neves. "We think there will be a second round and we continue to view her as the favorite to win it, though by a smaller margin."
The poll, published by Globo TV News and O Estado de S.Paulo newspaper, interviewed 2,002 eligible voters between May 15 and 19 and has a margin of error of plus/minus 2 percentage points. (Reporting by Anthony Boadle; Editing by Chizu Nomiyama and James Dalgleish)