The US ambassador to South Korea has been attacked by a knife-wielding man shouting anti-war slogans during a public event at an arts centre in Seoul.

The ambassador, Mark Lippert, was assaulted during a breakfast conference on Thursday as he was preparing to give a lecture about prospects for peace on the divided Korean Peninsula.

The US embassy said Lippert was in stable condition after surgery at a Seoul hospital. Hours after the attack Lippert tweeted that he was "doing well and in great spirits".

The suspect, identified by police as Kim Ki-jong, 55, was immediately apprehended at the scene. Police said he slashed Lippert on the face and wrist with a knife. Kim had a previous conviction for hurling a stone at the then Japanese ambassador to Seoul in 2010, police said.

"We have detained him and are investigating the cause of the attack and other circumstances," said district police chief Yoon Myung-soon.

Sources told Al Jazeera that Kim is the head of a relatively small civic organisation that has been calling for peace and reconciliation with North Korea.

According to witnesses, he repeatedly shouted "No drills for war." He was apparently referring to the ongoing large-scale South Korea-US military exercise, which occurs every year around this time.

Anti-US protesters in Seoul have recently demonstrated against the drills that North Korea says are preparation for an invasion. Seoul and Washington say the exercises, which will run until the end of April, are defensive and routine.

North Korea's official KCNA news agency described the attack as "deserved punishment for the warmongering United States", calling it "the knife of justice" that it said reflected the anger of South Koreans opposed to the military exercises.

On Monday, the first day of this year's drills, North Korea test-fired short range missiles in reaction to the exercises.

'Attack on alliance'

Korean President Park Geun-hye condemned the attack, saying it was an attempt to strike at the military alliance between Seoul and Washington.

"The incident is intolerable because it is not only a physical attack on Ambassador Lippert, but also on the South Korea-US alliance," she said in a statement.

Lippert, 42, became ambassador in October 2014 and has been a regular presence on social media and in speeches and presentations during his time in Seoul.

He is a former Pentagon official who served as a foreign policy adviser to Barack Obama when he was a senator from Illinois.

A US official said Obama called Lippert after the attack.

"The president called US ambassador to the Republic of Korea, Mark Lippert, to tell him that he and his wife Robyn are in his thoughts and prayers, and to wish him the very best for a speedy recovery," National Security Council spokesperson Bernadette Meehan said in a statement.

US Secretary of State John Kerry also expressed his sympathies on Twitter.