JERUSALEM — Ahed Tamimi, a Palestinian teenager whose angry altercation with an Israeli soldier outside her West Bank home made her a worldwide symbol of resistance but quickly got her jailed without bail, was sentenced in a military court on Wednesday to eight months in prison.

Ms. Tamimi, 17, accepted a plea bargain that will end her trial and should bring about her release in July, her lawyer said. It includes a fine of about $1,400 and a three-year suspended sentence.

On Dec. 15, a few hours after a cousin of Ms. Tamimi’s was shot in the face with a rubber bullet during a clash between villagers of Nabi Saleh and Israeli forces, Ms. Tamimi erupted at a pair of heavily armed soldiers as they took up a position in the front yard of her home.

As her mother streamed the confrontation live on Facebook, Ms. Tamimi, wearing a kaffiyeh over her denim jacket, screamed at, punched, slapped and kicked at one of the soldiers, an officer.

The officer faced her impassively, absorbing some blows, evading others, but never striking back at her, then finally turned and, with his comrade, walked away. A few days later, a clip of the scuffle was broadcast on Israeli television, setting off a debate on both sides of the conflict and turning the blonde, blue-eyed and seemingly fearless teenager into a hero for supporters of the Palestinian cause.

Israelis argued over whether the soldiers had demonstrated admirable forbearance and fortitude or a kind of weakness and vulnerability that could send dangerous signals to the country’s enemies. Palestinians, while showering Ms. Tamimi with praise, asked whether publicizing the video might have been counterproductive, by showing the soldiers behaving with restraint, or helpful, by showing that even unarmed resistance can be effective.

But Ms. Tamimi, whose family is well known for its protests against the Israeli occupation of the West Bank, also quickly became a symbol of how harshly the military justice system can treat young Palestinians. She was arrested in the middle of the night after the video’s broadcast on television. Her mother and a 20-year-old cousin, Nour Tamimi, were also charged. And their trial in a military prison was closed to the news media to protect Ms. Tamimi’s privacy, according to Israeli officials, though her defense lawyer, Gabi Lasky, asked to waive that, insisting that publicity would provide far better protection.

All three women agreed to plea bargains on Wednesday. Ahed Tamimi pleaded guilty to attacking the soldier and to two other counts of disrupting a soldier and incitement, the Israeli military said. Other charges, including stone-throwing, were dropped.

Nour Tamimi was sentenced to the time she had spent behind bars before being released on bail, about two weeks. Ahed’s mother, Nariman Tamimi, who was charged with incitement for showing the altercation live on Facebook, was sentenced to eight months in prison, a suspended sentence and a fine of about $1,700. Mother and daughter are both expected to be released in July.

On social media, Wednesday’s plea bargains prompted instant comparisons to the case of Elor Azaria, the Israeli soldier convicted of manslaughter for fatally shooting an already-wounded Palestinian attacker in the West Bank city of Hebron in 2016. On Monday, the military said Mr. Azaria would be released early, for good behavior, on May 10. His 18-month sentence had previously been reduced to 14 months, but he will now have to serve only a few weeks more in prison than Ms. Tamimi will under her sentence.