Last week Tripoli stopped issuing visas to most European citizens, a step that was linked to the row with Switzerland.
Goeldi was sentenced to four months in jail by a Libyan court for having allegedly overstayed his visa and conducting illegal business activity.
Following the Libyan government's ultimatum, Salah Zahaf, Goeldi's lawyer, told the AFP news agency: "He will leave the embassy and turn himself in voluntarily."
Zahaf said he expected Goeldi to be taken to Ain Zara prison near Tripoli, and that he had been instructed to ask the Libyan justice system for an amnesty.
Relations between Libya and Switzerland have been strained since July 2008, when Hannibal - a son of Muammar Gaddafi, the Libyan leader - was arrested in the Swiss city of Geneva after two workers complained he had mistreated them.
The row escalated when Libya swiftly detained Hamdani and Goeldi and confiscated their passports.
It deteriorated further last year when a tentative political deal between Swiss and Libyan ministers fell through.