A 12-year-old Palestinian girl who was imprisoned after she confessed to planning a stabbing attack in a West Bank settlement will be released early, Israel's prison service said Monday, capping a saga that drew attention to the dual legal system in the West Bank.

The case has put Israel's military justice system in a tough spot as it deals with a girl who has pleaded guilty to a crime, yet has not even completed the seventh grade. She is believed to be the youngest female Palestinian ever sent to an Israeli prison.

According to court documents provided by the military, the girl, whose name could not be published because of her age, approached the West Bank settlement of Carmei Tsur on Feb. 9 with a knife hidden under a shirt.

A security guard ordered her to halt, and a resident instructed her to lie on the ground and told her to give up the knife, which she did. An amateur video clip shown on Israeli TV showed the resident asking the girl, who was wearing her school uniform, whether she had come to kill Jews, and she said yes. She later pleaded guilty to attempted manslaughter in a plea bargain and was sentenced to 4 1/2 months in prison.

Last week, the girl's family appealed to Israeli military and prison officials to release her, citing her age.

"Prison is not a place for a small child," said Abeer Baker, one of the girl's lawyers. "If it was a Jewish girl, she wouldn't stay in prison for even one hour because it is forbidden according to the Israeli law."

Israel captured the West Bank in the 1967 Middle East war, and Palestinian residents there are subject to a system of military law that can sentence suspects as young as 12 to prison.

By contrast, Israeli settlers, as well as Jewish and Arab citizens of Israel, are subject to Israeli civil law, which does not allow anyone under 14 to go to prison.

Palestinian residents of east Jerusalem, which Israel annexed after the 1967 war, are also subject to Israeli civil law. Last week, for instance, the Ynet news site reported that an 11-year-old Palestinian boy from Jerusalem convicted in a stabbing on the city's light rail has been sent to a juvenile facility run by Israeli social services.

According to Israel's prison service, 437 Palestinian minors were in Israeli prisons as of Feb. 29, the most recent date that statistics were available. Of those, 12 were female.

The 12-year-old was the only girl under age 14, according to the data. In addition, four Palestinian boys under 14 were in Israeli prison. The Israeli human rights group B'Tselem said it was not familiar with any other instance in which a girl so young was imprisoned.

B'Tselem, citing court records, said the girl was interrogated twice without either an attorney or her parents being present after being caught outside the settlement. Nine days after the incident, her lawyers reached a plea bargain that convicted her of voluntary attempted manslaughter and bearing a knife, and she was sentenced to the prison term, and her parents were fined about $2,000, according to the court documents.

In the court documents, the girl said she understood the terms of the plea bargain and her sentence.

Tareq Barghout, another lawyer assisting the girl, said the court accepted a request to move her to a female juvenile facility in the West Bank but that her family refused, fearing it was filled with drug addicts and violent offenders.

"This child is a victim of the Israeli court and her family," he said, "the court because it has left a child in prison and the family because they refused a reasonable solution."

Lawyers and relatives say she was not allowed to see her mother until March 28, about six weeks after the incident, and that the girl is not allowed physical contact with her mother.

"It was very difficult that I couldn't hug her when I visited her," said her mother, Sabha al-Wawi. "I demand her release. She's a minor."

The incident came amid nearly seven months of violence in which Palestinians have killed 28 Israelis and two Americans in stabbings, shootings and car-ramming attacks in Israel and the West Bank. At least 188 Palestinians have died from Israeli fire. Israel says most were attackers, and the rest died in clashes with Israeli security forces.

Many of the Palestinian attackers have been teenagers or in their early 20s. The girl came from Halhoul, a village near Hebron, a city that has been a focal point of violence.

Israelis and Palestinians have offered different explanations for why so many young Palestinians have been involved. Israel blames incitement by Palestinian leaders and on social media. Palestinian officials say it is the result of despair living under Israeli occupation. Others have said the assailants were suicidal, had personal problems, or engaged in copycat attacks.

The girl's family said it could not explain what motivated her to go out that day with a knife and questioned whether she had even really tried to carry out an attack.

"We were surprised," her mother said. "If it's true, we don't know the reason why. She wasn't under any pressure at home."

Her father, Ismail al-Wawi, said he had worked legally in Israel for 25 years -- indicating he was not considered a security threat. After his daughter's arrest, he said his work permit was revoked.

Prison service spokesman Assaf Librati said authorities had decided Sunday to free the girl on April 24 -- six weeks before her scheduled release. He said the decision was made because of her "young age."

The girl has been held in a wing for female minors and attends classes, he said. "There is a school where they get, in accordance with the law, the basic education they need," Librati said.

She gets "conditions according to international law," including health care, as well as visits from social workers and relatives, he said. Family visits are allowed once or twice a month, he added. She saw her mother Monday.

"Is it possible that a 12-year-old girl is able to stab?" the mother said. "No. she does not pose a threat, not only to an armed soldier, but to anyone."