The judges said Mr Lubanga could not be guaranteed a fair trial as prosecutors had withheld evidence from the defence.
His release will be delayed by five days, pending a prosecution appeal.
Mr Lubanga, who has been in custody for two years, denies charges of recruiting child soldiers during the Democratic Republic of Congo's conflict.
Four million people are estimated to have died during the conflict in the DR Congo.
Mr Lubanga led the Union of Congolese Patriots (UPC) militia in the north-eastern Ituri district, where fighting continued long after a 2002 peace deal.
In a statement released early last year, the prosecution argued that children had been snatched as they walked to school and forced to fight for Mr Lubanga's ethnic Hema militia against their Lendu rivals.
But his lawyers said he was trying to end the conflict and is being punished by the international community for refusing to give mining concessions to foreign firms in areas he controlled.
The ICC, based in The Hague, was set up in 2002 as the world's first permanent war crimes court.
It was designed to end the need for various ad hoc war crimes courts - including the chambers created to deal with war crimes committed in the former Yugoslavia and the genocide in Rwanda.