A close ally of embattled Brazilian President Luiz Inacio Lula da Silva has been elected speaker of parliament.
After the vote, Rebelo was carried shoulder-high by supporters
Aldo Rebelo, of the government-allied Communist Party, narrowly beat Jose Thomaz Nono to win the key post in the lower house of Congress.
Brazil's governing coalition has been weakened by a corruption scandal.
Correspondents say holding the speaker's post will help it set the legislative agenda and fend off probes into the irregularities.
Under Brazil's constitution, the leader of the lower house is third in line to the presidency, after Vice President Jose Alencar.
The previous speaker, Severino Cavalcanti, stepped down to fight allegations that he took bribes from the owner of a restaurant in Congress.
The Workers' Party of President Lula has been dogged by corruption scandals in recent months.
The accusations have damaged his government's chances of re-election in 2006 and held up a programme of economic reforms.
Second round edge
In the first round of voting, Mr Rebelo and Mr Nono received an equal number of ballots in the 512-seat lower house.
But in a run-off vote, Mr Rebelo, 49, edged ahead 258-243.
"The deputies showed this house is a free house and an independent institution," he said.
Lula was quick to congratulate Mr Rebelo, who can limit Congressional investigations of alleged corruption and recommend more lenient sanctions for anyone found guilty.
Critics said that the government had ensured Mr Rebelo received enough votes by releasing public money for projects backed by deputies allied to the Workers' Party.