The International Criminal Court could soon drop its demand that Saif al-Islam Gaddafi be transfered to the Hague for trial, officials have told the BBC.
They say the most prominent son of the former Libyan leader Muammar Gaddafi could instead be tried inside Libya but under the supervision of the ICC.
The argument over who should try him has been going on ever since he was captured in November last year.
The ICC has indicted him for crimes against humanity.
Now the Libyan justice ministry says a deal is being finalised where Mr Gaddafi can be tried in Libya but with security and legal supervision by the international court.
The BBC’s Jon Donnison, in the Libyan capital Tripoli, has been told by a western official with good knowledge of the case that a deal is close to being agreed.
But the official warned it could be months before any trial might begin.
The ICC’s chief prosecutor Luis Moreno Ocampo is due to visit Libya this week.
Human rights groups have argued that the Libyan justice system is not capable of dealing with such a high-profile case.
Saif al-Islam, 39, is currently being held by a militia in the Zintan region of Libya. He was once expected to succeed his father, Libya’s late leader, Col Muammar Gaddafi.
The group has given no indication of when they will hand him over to the Libyan government.
If tried in Libya, Mr Gaddafi could face the death penalty.