Almost a year to the day since French-Algerian writer Boualem Sansal was arrested on arrival at Algiers airport, the Algerian president has pardoned him and allowed him to leave the country.

Sansal, 81, has been at the centre of a bitter diplomatic row between Paris and Algiers, and President Abdelmadjid Tebboune's decision came in response to a direct approach from German President Frank-Walter Steinmeier.

The writer arrived in Germany on a military plane on Wednesday evening and was taken to hospital.

French President Emmanuel Macron, who spoke to Sansal by phone, said France had used respect and calm to bring about his freedom.

I thank President Tebboune for this act of humanity, said Macron.

Although Paris had for months sought to lower tensions with Algeria, it was the German president's role that secured Sansal's release because of his good relations with Algeria's leader.

French ambassador Stéphane Romatet told French radio that the crisis in relations was so deep that from the start we knew a happy outcome... would go through a trusted third party, and the German solution quickly came forward.

Steinmeier had asked President Tebboune to pardon Sansal given his advanced age and fragile health, allowing the writer to receive medical treatment in Germany.

Sansal, who is being treated for prostate cancer, was sentenced to five years in prison in July for allegedly undermining national unity with remarks questioning Algeria's borders. The novelist has long been a critic of Algeria's government, which had not responded favorably to France's earlier appeals for clemency.

Relations between Algeria and France had been on the decline, particularly following President Macron's announcement to recognize Moroccan sovereignty over Western Sahara. This declaration aggravated Algeria, which supports the pro-independence Polisario Front in the disputed territory.

The diplomatic situation deteriorated further when Algeria reacted angrily to the arrest of one of its consular staff in France over the kidnapping of a government critic.

Some French commentators suggest that right-wing political figures in France contributed to the escalation of tensions with Algeria.

While the recent replacement of France's Interior Minister signaled a potential shift towards improvement in relations, numerous challenges remain, particularly with the case of French sports journalist Christophe Gleizes, who was sentenced to seven years in Algeria.

French Foreign Minister Jean-Noël Barrot expressed hope for further resolutions, remaining focused on securing Gleizes's release.