Lubanga is accused of enlisting and conscripting children aged under 15 for his Union of Congolese Patriots, to kill members of a rival tribe in the 1998-2003 war in the Democratic Republic of Congo.
He has pleaded not guilty and described himself as a politician, not a warlord.
Order on hold
The court said that the release order would not be implemented immediately because an appeal can be filed within five days.
The prosecution said it would appeal.
"We are confident that the protective measures required will be implemented very soon, and that the Appeals Chamber will clarify the legal issues at hand," the Office of the Prosecutor said in a statement.
Chances that Lubanga will be released in the short term are considered small because the court built a number of conditions into its ruling.
"If an appeal is filed within the five-day time limit against this order granting release, and if a request is made to suspend its effect, the accused shall not leave detention until the Appeals Chamber has resolved whether this order granting release is to be suspended," the court said.
The court also said that an order releasing Lubanga will be put into effect only after arrangements have been made for his transfer to a state that is obliged to receive him.
Jan Wouters, a professor of international law at the Catholic University of Leuven, said that it still made sense to ask for Lubanga's release.
"A fair trial also means a timely trial. In that sense the court has an obligation to set an example," Wouters said.
The ICC is also trying other accused Congolese warlords for crimes committed during the fighting in the giant, resource-rich African country.
Lubanga's trial resumed in January, six months after prosecutors finished presenting their case.
His defence has argued that the child soldiers who testified against him made up their stories.