Turkish president Recep Tayyip Erdogan embraced the Saudi crown prince Mohammed bin Salman on a visit to Saudi Arabia, signalling the end of a years-long spat between the two men over the murder of the journalist Jamal Khashoggi.

The encounter on Thursday night between Erdogan and the day-to-day ruler of the Gulf kingdom is highly symbolic, marking a significant shift in relations between the two regional powers after years of tensions caused by the killing of the former Washington Post columnist at the Saudi consulate in Istanbul.

Although Erdogan never explicitly accused Prince Mohammed over the Khashoggi’s murder, which was carried out by a security team dispatched from Riyadh, he made clear that he blamed him for it. He had said the killing was ordered by the “highest levels” of the Saudi government while stressing that he did not blame the country’s ruler King Salman, Prince Mohammed’s father and the head of state.

A drip-feed of leaks by Turkish authorities with grizzly details about the killing — including the claim that a forensics expert used a bone saw to dismember Khashoggi’s body — was seen by analysts as an attempt to tarnish the image of the crown prince in the west.

Erdogan’s two-day visit to Saudi Arabia, his first since the killing of Khashoggi, follows a months-long drive by Ankara to repair its damaged ties with Riyadh. It is part of a broader effort by the Turkish president, who is gearing up for elections due next year against the backdrop of a troubled economy, to mend ties with one-time regional foes and attract foreign investment.

Speaking before his departure, Erdogan said he hoped to “open the doors to a new era” in relations with Saudi Arabia.

He said the two nations wanted to increase their political, economic, military and cultural co-operation, and voiced hope that his visit would “further strengthen our relationship on the basis of mutual respect and trust”.

Saudi Arabia has proved one of the most challenging relationships to fix as Erdogan embarked on a significant shift in foreign policy at the start of last year. The Turkish president launched a drive to rebuild his country’s ties with former regional adversaries including the United Arab Emirates, Egypt, Armenia and Israel — as well as with the west.

The first significant breakthrough came earlier this month when an Istanbul court halted the trial of 26 Saudis who were being tried in absentia for the Khashoggi killing — a key demand from Riyadh. Saudi Arabia had already convicted and jailed a number of the suspects, although it cleared a senior aide to Prince Mohammed and a former top intelligence official accused of involvement in the killing.

At the same time, Turkish business groups said the Gulf state had begun easing the unofficial embargo that had hit the country’s exports and was widely seen as an act of retaliation against Turkey for its response to the Khashoggi affair.

Turkish officials hope the mending of ties with the oil-rich kingdom will boost their economy through Saudi investment in their country and the rekindling of trade.

Turkey’s finance minister Nureddin Nebati held a video call on Wednesday with his Saudi counterpart Mohammed al-Jadaan in order to “exchange ideas about improving co-operation on the economy, trade and investment”.

Erdogan sorely needs inflows of foreign capital to help plug a trade deficit that is being fuelled by soaring global energy and commodity prices in the wake of Russia’s invasion of Ukraine.

Analysts say Turkey’s large import bill, combined with soaring inflation, risks putting renewed pressure on the volatile Turkish lira in the months ahead.

Erdogan, a practising Muslim, travelled early on Friday to the city of Mecca to perform prayers at the holiest site in Islam in the final days of the sacred month of Ramadan.