He added that his administration had told the Libyan government that Megrahi should not receive a hero's welcome and should be placed under house arrest.
In London, a spokesman for the Foreign Office said any decision to release Megrahi "was for the Scottish government and ministers to take, as they have done".
Correspondents say the Libyan authorities will regard his release as a triumph.
Hundreds of people waved Libyan and Scottish flags as his plane landed at Tripoli airport at 1830 GMT.
Within minutes Megrahi was whisked away for a meeting with his elderly mother, the BBC's Christian Fraser reports from the scene.
It was a jet owned by leader Col Muammar Gaddafi that carried Megrahi back to Libya after his release on Thursday from Scotland's Greenock Prison.
On arrival, he appeared beside the Libyan leader's son, Seif al-Islam Gaddafi, who described his release as a courageous step by the British and Scottish governments.
Local media reports said Megrahi would probably meet Col Gaddafi on Friday.
Christian Fraser, BBC News, Tripoli
Well before the Scottish justice minister had announced his decision, Col Muammar Gaddafi's private jet was on its way to Glasgow.
Until now, Libyan officials have been careful not to comment in case they jeopardised the release, wary of this last-minute intervention by the US.
Officially there are unlikely to be any triumphant statements here, but given the personal involvement of Mr Gaddafi it will no doubt be seen as further evidence of his growing stature on the international stage.
It is rumoured that he has asked to see Megrahi when he returns, and the timing is perfect. In 12 days' time, Libya celebrates the 40th anniversary of the revolution that brought Mr Gaddafi to power.
The Scottish government said it had consulted widely before Justice Secretary Kenny MacAskill made his decision on applications for Megrahi's compassionate release or his transfer to a Libyan jail.
Mr MacAskill told a news conference he had rejected the application for a prisoner transfer.
However, after taking medical advice it was expected that three months was a "reasonable estimate" of the time Megrahi had left to live.
He said that fact that Megrahi's victims were shown no compassion was "not a reason for us to deny compassion to him and his family in his final days".
In a statement released after his departure from HMP Greenock, Megrahi continued to protest his innocence, saying his final days were "being lived under the shadow of the wrongness of my conviction".
"I have been faced with an appalling choice: to risk dying in prison in the hope that my name is cleared posthumously or to return home still carrying the weight of the guilty verdict, which will never now be lifted."
Megrahi's return was welcomed in Libya.
"This person is innocent, thank God he's coming home. This is a cheerful day for the whole Libyan people," one man in Tripoli said.
But the families of American victims of the Lockerbie bombing reacted angrily to the news.
Kara Weipz, of Mt Laurel, New Jersey, who lost her brother Richard Monetti, said: "It is an utter insult and utterly disgusting... I don't show compassion for someone who showed no remorse."
New York state resident Paul Halsch, whose 31-year-old wife was killed, said of Mr MacAskill's decision: "This might sound crude or blunt, but I want him returned from Scotland the same way my wife Lorraine was and that would be in a box."
However, British relatives' spokesman Dr Jim Swire, who lost his daughter Flora in the atrocity, reiterated his view that Megrahi had "nothing to do with" the bombing.
"I don't believe for a moment that this man was involved in the way that he was found to have been involved," he said.
Megrahi was convicted of murder in January 2001 at a trial held under Scottish law in the Netherlands.
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.