Rodrigo Maia of the right-wing Democrats party was elected with 285 out of 460 votes in a second-round election in the Chamber of Deputies.
That puts the 46-year-old banker first in line to succeed the president in Latin America's largest economy.
After months of political upheaval, Temer, Rousseff's vice president, took over from her on May 12, when the Senate suspended her to face an impeachment trial over accusations of fudging the government's accounts to make them look better in an election year.