Turkey's Recep Tayyip Erdogan on Saturday unveiled a new cabinet lineup, naming a powerful spy chief as foreign minister and market friendly Mehmet Simsek as finance minister, hours after swearing in for a third term as president.

Erdogan took oath of office in parliament after winning a historic runoff election to extend his two-decade rule and promised to serve "impartially".

He also called for unity and the anger and resentment of the campaign to be set aside as he spoke during a lavish ceremony at his presidential palace in the capital Ankara attended by dozens of world leaders.

Turkey's transformative but divisive leader won the May 28 runoff against a powerful opposition coalition, despite an economic crisis and anger over the response to a February earthquake that killed more than 50,000 people.

Erdogan won 52.18 percent of the vote while his secular rival Kemal Kilicdaroglu scored 47.82 percent, official results show.

"As president, I swear upon my honour and integrity, before the great Turkish nation... to work with all my power to protect the existence and independence of the state... and to fulfil my duty impartially," Erdogan said in parliament after a ceremony outside the building where he saluted soldiers under pouring rain.

Supporters in parliament gave Erdogan a minute-long standing ovation after his swearing in, while some opposition lawmakers refused to stand up.

In his oath, Erdogan also promised not to deviate from the rule of law and the secular principles of the republic founded by Mustafa Kemal Ataturk 100 years ago.

Turkey's longest-serving leader, who has survived mass protests, a corruption scandal and a failed coup attempt since he came to power in 2003, now faces significant immediate challenges in his third term, including the slowing economy and tensions with the West.

- New cabinet -

Erdogan changed almost all his cabinet members except for his health and culture ministers.

He named former deputy prime minister Mehmet Simsek, a reassuring figure with international stature, as treasury and finance minister.

Addressing the country's economic troubles will be Erdogan's first priority, with inflation running at 43.70 percent, partly due to his unorthodox policy of cutting interest rates to stimulate growth.

A former Merrill Lynch economist, Simsek is known to oppose Erdogan's unconventional policies.

He served as finance minister between 2009 and 2015 and deputy prime minister in charge of the economy until 2018, before stepping down ahead of a series of lira crashes that year.

Erdogan appointed the head of the National Intelligence Organisation (MIT), Hakan Fidan, as foreign minister.

Fidan has been at the helm of the MIT since 2010 -- and Erdogan once called the 55-year-old his "secret-keeper".

- 'Let's make peace'-

Erdogan, standing next to his wife Emine, promised to embrace all segments of society during a ceremony at his palace earlier in the day.

"We will embrace all 85 million people, regardless of their political views, origins, creeds or sects," he said, hoping that his appeal would be reciprocated also by his opponents.

"Turkey needs unity and solidarity more than ever," he said.

The polarisation in society has deepened under the rule of Erdogan -- called "Reis" by his supporters ("the chief").

"We want all opposition segments, including journalists, writers, civil society, artists and politicians, to reconcile with the national will," he said.

"If there is resentment, if hearts are broken, let's find a way to make peace."

Azerbaijan's President Ilham Aliyev, Venezuelan President Nicolas Maduro, Iran's vice president Mohammad Mokhber, Hungary's right-wing Prime Minister Viktor Orban and the speaker of the lower house of Russia's parliament, Vyacheslav Volodin, were among the foreign guests at the ceremony.

In the latest sign of a thaw between the two arch foes, Armenia's Prime Minister Nikol Pashinyan was also present.

NATO allies are anxiously waiting for Ankara to green-light Sweden's drive to join the US-led defence alliance, before a summit in July.

Erdogan has delayed approving the application, accusing Stockholm of sheltering "terrorists" from the outlawed Kurdistan Workers' Party (PKK) which is listed as a terror group by Ankara and its Western allies.

NATO chief Jens Stoltenberg and Sweden's former prime minister Carl Bildt, who attended the ceremony at Erdogan's palace, are expected to press him to drop his opposition to Stockholm's bid.