Ibrahim el-Zakzaky had been in detention since 2015 when he was arrested after a clash in which the army killed an estimated 350 people at an IMN compound and a nearby mosque and burial ground in northern Kaduna state.
El-Zakzaky and his wife, who was also arrested in 2015, had been facing a range of charges filed by the state government in 2018, including aiding and abetting homicide, unlawful assembly and disruption of public peace.
"None of the 15 prosecution witnesses proved they committed the offence," lawyer Sadau Garba told the AFP news agency after Wednesday's hearing, adding that the couple had been acquitted and "regained their freedom today".
El-Zakzaky's continued detention has led to street protests in Nigeria and abroad [File: Dar Yasin/AP]Lead prosecutor Dari Bayero confirmed that the pair had been freed but said the state was planning to appeal.
"The court ruled that none of the witnesses we presented in court gave convincing proof that the duo were guilty," Bayero said. "This doesn't mean they can't be re-arraigned ... we are certainly going to file charges against the duo at appeal."
Justice Gideon Kurada ruled there were no charges to answer and acquitted the pair.
Shias are a small minority in Nigeria, where about half the population is Muslim and overwhelmingly Sunni.
'Victory for perseverance'
IMN spokesperson Ibrahim Musa said the ruling was "a victory for perseverance in the face of extreme persecution".
El-Zakzaky's supporters at the court said they feared police would arrest him again following his release.
The police and Nigeria's attorney general have not commented on the court ruling.
Meanwhile, Amnesty International urged the Nigerian authorities to "immediately comply" with the court order.
In December 2015, troops launched a ferocious clampdown on the IMN when its members blocked the convoy of the army chief of staff during a religious procession.
Human rights groups said at the time that some 350 IMN members were killed during two days of clashes and later buried in mass graves.
The army initially denied the events and said a soldier was killed by armed Shia fighters.
El-Zakzaky's continued detention has led to street protests in the nation's capital Abuja, sparking violent clashes with security forces that have killed dozens of lives.
The Nigerian government officially outlawed the group in 2019.
That same year, 100 arrested members were released in two batches after a court acquitted them.