REYKJAVIK (Reuters) - Icelanders elected historian Gudni Johannesson on Saturday as their first new president in 20 years, amid distrust of politicians and business leaders after the 2008 global financial crisis and the Panama papers scandal.

Slideshow ( 2 images )

The final count showed 39 percent of Icelanders voted for Johannesson as president, public broadcaster RUV reported. The post is largely ceremonial but does carry powers to block legislation.

Contenders included a former prime minister and central bank governor.

Johannesson, a lecturer at the University of Iceland who has said he has never been a member of a political party, will take office on Aug. 1.

In his campaign, he advocated a constitutional clause allowing citizen-initiated referendums over parliamentary bills, saying it would help ensure the nation always had the final say in the largest issues affecting it.

Icelanders’ faith in authorities was shaken by years of austerity measures and capital controls, which were imposed to restore a shattered economy after the country’s largest banks collapsed in 2008 during the global financial crisis.

President Olafur Grimsson, 73, who has served five straight four-year terms, had been ahead in polls until May, when he withdrew his candidacy after leaked documents called the Panama papers showed his wife had links to offshore accounts.

Grimsson had begun his candidacy citing a need for stability after then-Prime Minister Sigmundur Gunnlaugsson resigned in 2015 when the Panama papers showed he also had owned an offshore company in a tax haven together with his wife.

Neither Gunnlaugsson nor Grimsson have been accused of doing anything illegal related to the offshore dealings. But the links still raised ire among many Icelanders, sparking demonstrations in the capital.

Iceland has been gradually recovering from the 2008 financial meltdown in recent years. Economic growth is expected to reach 4 percent this year and unemployment is at a pre-crisis levels.

But gross national income per capita is still down by a quarter since 2007 and a tenth of the 330,000 Icelanders have fallen into serious loan default, with thousands of homes repossessed.

Candidates in presidential elections in Iceland run as independents.