Lebanon's parliament has elected Michel Aoun as president, ending a political stand-off that has left the post empty for more than two years.
The newly-appointed president, a Maronite Christian, vowed to protect Lebanon from "regional fires" - a reference to the conflict in Syria.
Mr Aoun was backed by the powerful Shia Islamist group, Hezbollah.
His candidacy was blocked by the rival, Sunni-dominated Future Movement until a deal was struck earlier this month.
It will reportedly see the Future Movement's leader, Saad Hariri, become prime minister.
Mr Aoun, an 81-year-old former army general, secured 83 votes in the 128-seat chamber when MPs convened for their 46th attempt to choose a head of state.
The stalemate has paralysed Lebanon's government, which is struggling to deal with deep divisions over the five-year civil war in neighbouring Syria and the arrival of more than one million refugees.