SEOUL, South Korea (AP) — The South Korean army captured a soldier Monday who it says killed five comrades and then fled into the forest where he holed up with a rifle for two days before shooting himself as pursuers closed in.

The massive manhunt ended when the 22-year-old sergeant, surnamed Yim, shot himself in the upper left chest as his father and brother approached, pleading with him to surrender, a Defense Ministry official said. The official, who spoke on condition of anonymity because of department rules, said Yim was taken to a hospital but his life wasn’t in danger. He didn’t elaborate.

Defense Ministry spokesman Kim Min-seok said the soldier would be handed to military investigators later. Soldiers retrieved Yim’s rifle and ammunition at the site.

South Koreans have worried about public safety in the wake of an April ferry disaster that left more than 300 people dead or missing. And some in Seoul have questioned the discipline and readiness of South Korea’s military in the face of near-constant threats from North Korea, which has recently staged missile and artillery drills, traded fire with the South at sea and threatened South Korea’s leader.

Troops had been chasing Yim since authorities said he killed five fellow soldiers and wounded seven Saturday night. He then fled his frontline unit with his standard-issue K2 assault rifle.

He fired Sunday on the soldiers chasing him, injuring a platoon leader. On Monday, officials said a South Korean soldier was wounded by suspected friendly fire.

Earlier Monday, troops surrounding Yim in the forest tossed him a mobile phone so he could talk to his father. They also threw him bread and bottled water. His parents went to the area to try to persuade him to surrender.

It wasn’t clear what triggered the rampage; there was no indication that South Korea’s bitter rival, North Korea, was involved.

Yim was scheduled to complete his nearly two years of mandatory military service in September, according to defense officials.

Initial personality tests in April of last year put Yim within a group of soldiers who need special attention and are unfit for frontline duty, according to the Defense Ministry. But tests last November concluded he had improved and could serve in the frontline area, defense officials said.

Hundreds of thousands of troops from the rival Koreas square off along the world’s most heavily armed border. The Korean Peninsula is still technically in a state of war as the 1950-53 Korean War ended with an armistice, not a peace treaty.

Shooting rampages against fellow soldiers happen occasionally. South Korea’s military maintains a conscription system requiring all able-bodied men to serve about two years because of the North Korean threat.

In 2011, a 19-year-old marine corporal went on a shooting rampage at a Gwanghwa Island base, just south of the maritime boundary with North Korea. Military investigators later said that the corporal was angry about being shunned and slighted and showed signs of mental illness.

In 2005, a soldier tossed a grenade and opened fire at a front-line army unit in a rampage that killed eight colleagues and injured several others. Pfc. Kim Dong-min told investigators he was enraged at superiors who verbally abused him.

___

Associated Press writers Jung-Yoon Choi and Foster Klug contributed to this report.