Of those voting in Lebanon's 127-member parlaiment, 118 voted in favour of Sleiman becoming president.
Six of the ballots cast were blank, signifying a protest vote or reservations over Sleiman's election.
Rula Amin, Al Jazeera's correspondent in Beirut, said many Lebanese intellectuals had said they would have preferred a civilian candidate for the post.
But many other observers believe the selection of Sleiman was crucial in order to end the country's political crisis.
The foreign ministers of Syria and Iran, which back Hezbollah, and European leaders were among the 200 dignitaries attending the parliamentary session.
Sleiman's election is part of a deal brokered on Wednesday in Doha, Qatar's capital, to end a political crisis that last month degenerated into violence.
Sixty-five people were killed when armed supporters of the Hezbollah-led opposition took control of much of Beirut after the government moved to outlaw the group's private communications network.
The clashes were the worst internal violence in Lebanon since the country's 1975-1990 civil war.
The Doha accord allows the opposition to have veto power on key policy decisions in a new cabinet of national unity.
But while it brought the country back from the brink of civil war, it failed to address many key issues, including Hezbollah's weapons stockpile.
Fouad Siniora, Lebanon's prime minister, said in an interview with the AFP news agency that he felt the deal was fair, especially in light of the latest violence that shook the country.
"We all gave in [for the sake of] the country and at the same time we got something in return for the country," he said.
"One has to look at the Doha accord as a package. It is a recognition by everybody who signed ... this agreement that weapons are in no way to be used against the Lebanese for political reasons."
Elias Hanna, a former chief of the Lebanese army, told Al Jazeera that Sleiman was a wise choice for the presidency.
"I think Sleiman came as a solution for this country, that's why we have this consensus," he said.
"There is a lot of criticism of the army and I do agree that there were a lot of deficiencies in the army. But [Sleiman's election] is a solution for Lebanon."
Earlier this week, Sleiman told Lebanese media that it would be impossible to "save the country on my own".
"This mission requires the efforts of all. Security is not achieved by force but joint political will."
The presidency has been vacant since November, when Emile Lahoud stepped down at the end of his term with no elected successor because of political disputes.
Nineteen previous parliamentary sessions to formally elect a new president failed due to boycotts by the opposition.
Though many see Sleiman as pro-Syrian in outlook, in nearly 10 years as head of Lebanon's armed forces, he has managed to avoid taking sides.
As the new head of state, he will need to show he is a neutral figure if he is to reconcile the interests of the Western-backed parliamentary majority and the opposition.