PARIS — A former presidential candidate and longtime star of the French center left was fired as her country’s ambassador to the North and South Poles on Friday after mounting repeated attacks on one of President Emmanuel Macron’s flagship policies.

Ségolène Royal, who was the Socialist Party’s unsuccessful candidate in the 2007 French presidential election and later a senior official under the presidency of her former partner, François Hollande, was appointed to the diplomatic post by Mr. Macron in 2017.

In recent weeks, however, she has engaged in an increasingly messy public confrontation with Mr. Macron’s administration — including over the process of her own impending dismissal — and faced the news that public prosecutors were investigating whether she had used Foreign Ministry funds for unrelated work, an accusation she denies.

“The Minister for Europe and Foreign Affairs proposed that Ségolène Royal no longer hold the position of Poles ambassador,” Sibeth Ndiaye, the French government’s spokeswoman, said on Friday.