Image copyright Reuters Image caption South Korean troops were deployed to Goseong town to search for the man after Saturday's attack

A South Korean soldier who killed five members of his unit has been captured after a failed suicide attempt, defence officials say.

The soldier, identified only as Im, shot himself in the chest and was being sent to hospital, they said.

His capture ends a tense stand-off in a forest near his outpost by the border with North Korea.

On Saturday evening Sergeant Im shot and threw a grenade at soldiers before fleeing with his rifle and ammunition.

Seven others were injured in the attack but are expected to live. It is not clear what the motive behind his attack was.

The incident sparked a massive manhunt, with thousands of troops deployed to block possible escape routes, guard the border between North and South Korea, and protect areas where civilians live, officials said.

Sgt Im at one point exchanged fire with troops, injuring one. Another soldier was also hurt from friendly fire.

He was eventually cornered on Sunday in a forest near Goseong town, in the eastern Gangwon province. His family was brought to the area to persuade him to turn himself in.

South Korea's Yonhap news agency quoted an army officer as saying that Sgt Im was in tears as he spoke to his father and brother.

Troops were reportedly so close to Sgt Im that they could toss him a mobile phone as well as food supplies.

Image copyright Getty Images Image caption Elderly residents in Goseong town were evacuated over the weekend after an exchange of gunfire

Yonhap earlier quoted an official as saying Sgt Im had "difficulties" adapting to military life. He was due to be discharged in three months.

The defence ministry spokesman has said the incident was "regrettable", adding: "We truly apologise for causing concern to the nation."

There have been similar incidents in South Korea's military, which operates a conscription system under which all men must serve two years.

Bullying and mental health problems have been blamed for previous attacks.

In 2011, a marine opened fire on his colleagues and tried to blow himself up with a grenade. Four soldiers were killed in the attack.

The two Koreas were divided at the end of the 1950-53 Korean War, which ended in an armistice rather than a peace treaty. As a result, they remain technically at war.