On Tuesday night, she apparently wandered out of a forest, asking for help, accompanied by a baby and a man who claimed to be her husband, according to witnesses.
The man is being investigated by Nigeria's joint intelligence center, according to a military statement.
Amina Ali is the first of the more than 200 Chibok schoolgirls kidnapped by Boko Haram to be freed after the two years in captivity, Nigerian military officials say.
The Sambisa Forest, believed to be the terrorist group's stronghold, has long been the suspected location of the girls. As many as 276 of them were kidnapped at gunpoint from their boarding school in Chibok in Borno, northeast Nigeria, on April 14, 2014.
At least 57 girls were able to escape soon after their abduction, but more than 200 of them remain missing.
Witness: She wandered out
The witness, Aboku Gaji, told CNN he was participating in a nightly patrol on the edge of the Sambisa Forest with the Civilian Joint Task Force, a vigilante group set up to help fight Boko Haram, when the girl and some companions wandered out around 7 p.m.
He said her name was Amina Ali Nkeki, and he recognized her as one of the missing schoolgirls, although she looked different and was in poor physical condition, as were the baby and man with her.
"Their bodies didn't look good," Gaji said. "They had had no bath and were in a dirty condition."
The young woman was part of a group asking for help, including a man who identified himself as her husband and the father of her baby, Gaji said.
The man said he had been kidnapped by Boko Haram from the town of Mubi, taken to Sambisa Forest and married to Nkeki.
Gaji and his commander took the girl to her house, in the settlement of Mbalala, where she was reunited with her mother, Binta Ali, Gaji said.
Army: We rescued her
The Nigerian government and army disputed the account, saying she was rescued by government troops that were working with the civilian force. Operations to find the missing girls have intensified recently with a deep push into Sambisa Forest, a military spokesman told CNN's Nima Elbagir.
"Troops of 25 Brigade Damboa in conjunction with Civilian JTF deployed in one of the blocking positions at Baale, near Damboa rescued one Miss Amina Ali and a suspected Boko Haram terrorist, Mohammed Hayatu, who claimed to be her husband," according to a military statement.
She was nursing a 4-month-old girl the military said was named Safiya.
Manasseh Allan, a Chibok youth leader who also confirmed the girl's rescue, said she was brought in clutching the baby she gave birth to in the hands of Boko Haram militants.
The army said Hayatu is being treated well and in line with the "rules of engagement regarding insurgents who voluntarily surrender to the military."
After an exam by air force medics the girl and her baby were handed over to the governor of Nigeria's northeastern Borno state, officials said.
She may be taken to Abuja on Thursday with her parents to meet the President, according to an army statement.
A distant relative of the Amina Ali, Yakubu Nkeki, said his wife had spoken to the mother of the young woman and confirmed that they had been reunited.
"It's a joyful time for me," said Nkeki, who is the father of another of the abducted girls. He said the rescued girl would be taken to the state capital, Maiduguri, on Thursday.
The military confirmed in a statement that "the suspected Boko Haram terrorist and the nursing mother have been taken to Maiduguri for further medical attention and screening."
'Bring back our girls'
The girls' kidnapping sparked global outrage, with Michelle Obama, Malala Yousafzai and a slew of other high-profile figures lending their weight to the #BringBackOurGirls campaign.
But Nigeria's government has proven powerless to recover the girls, most of whom were Christian, and are believed to have been forced by their captors to convert to Islam.
Last month, CNN obtained a video of some of the missing Chibok girls
that had been sent to negotiators by their captors as "proof of life," and showed it to some of the girls' mothers, who had not been shown the footage by officials.
Boko Haram, based mainly in Nigeria's northern states but responsible also for attacks in neighboring countries, is seeking to implement sharia law. According to a report released in November
, the Global Terrorism Index, Boko Haram was the world's deadliest terrorist group in 2014, responsible for 6,644 deaths, an increase of 317% from the previous year.
Two years ago, when CNN first visited Chibok after the mass abduction, parents described how they had followed their daughters' trail to the edge of the Sambisa Forest, which had been overrun by the Islamist insurgents several years earlier.
But with danger lurking amid the dense vegetation -- an ideal hiding place for the militants and their improvised explosive devices -- the parents were unable to go further.
Since then, Nigerian soldiers have infiltrated the forest and driven the militants from some of their territory.
But the group still holds land in the heart of the forest.
Nkeki Mutah, the vice chairman of the Chibok association of Abuja, told CNN that urgent action was needed to recover the girls.
"It is now left for the government to act as quickly as possible and we are calling on international leaders to act."