All hostages aboard a bus in the north-western Ukrainian city of Lutsk were freed on Tuesday as authorities stormed the vehicle and captured the armed attacker.
"There is no place for terrorism in any country," President Volodymyr Zelensky said in a statement, thanking everyone who had worked to free the hostages.
Thirteen hostages had been aboard the vehicle in the stand-off of more than 12 hours with the attacker, armed with a Kalashnikov assault rifle, a handgun and a grenade, according to the authorities.
"All the hostages have been freed! The terrorist has been detained," Deputy Interior Minister Anton Gerashchenko said in a statement. Ukraine's Security Service said no one had been injured in the incident.
Zelensky had posted a video to comply with the hostage-taker's demands, urging the public to watch the 2005 documentary film "Earthlings," about mankind using animals for food, pets and clothing.
"Everyone should watch the 2005 film 'Earthlings,'" Zelensky said in the six-second video posted on the social network Facebook. Three hostages were released at that time, two women and a child.
Zelensky also posted excerpts from a Twitter feed believed to have been used by the hostage-taker, including the demand that senior officials and clergy members declare themselves a "terrorist." The posts were later deleted.
"A crucial decision"
Interior Minister Arsen Avakov credited Zelensky with having made a crucial decision to end the hostage situation, without disclosing details.
"The president made a decision thanks to which all the hostages were kept alive and the terrorist was arrested," Avakov told reporters.
Media reports said the hostage-taker, identified by authorities as a two-time ex-convict and author of the online book "Philosophy of a Criminal," is considered to be suffering from psychological problems.
The hostage-taker had called police at the onset of the incident to inform them of the situation but then was reluctant to negotiate. A law enforcement official was able to bring bottled water to the bus almost 10 hours after the ordeal had begun.
Avakov had flown to the city, located about 400 kilometres west of Kiev, to oversee the police efforts, the Interior Ministry said.
Ukranian citizen born in Russia
The hostage-taker identified himself to police as "Maxim Plokhoi," Avakov's deputy, Gerashchenko, said in a statement. "Plokhoi" roughly translates as "wrongdoer."
Gerashchenko said the primary suspect had a different last name and was a 44-year-old Ukrainian citizen born in Russia.
The suspect had been twice convicted in Lutsk, in 1994 and 2005, including for fraud, extortion and illegal arms possession, Gerashchenko said.
A book authored under the name Maxim Plokhoi and available online, titled 'Philosophy of a Criminal,' describes having been incarcerated.
Gerashchenko quoted an excerpt from the book: "They have been correcting me for 15 years, but I have not been corrected, more likely the opposite. I have become more of who I am."