Ukrainian police freed 13 hostages and arrested an armed man who held them on a bus for more than 12 hours on Tuesday, after the country's president agreed to his demand to post a movie recommendation on social media, AFP reports.

The SBU security service said a joint operation had resulted in all the hostages being released unharmed after a police stand-off in the western city Lutsk with the man, who threatened to detonate an explosive device unless his strange requests were met.

The hostage situation seemed to be resolved swiftly after the man spoke on the phone with Ukrainian President Volodymyr Zelensky, who then recorded a short video, apparently meeting one of the man's demands.

Three hostages were quickly let go, followed by the rest about an hour later.

Footage published by Ukrainian officials showed police escorting people as armed special forces stood over a man lying face down on the pavement near the bus with his hands behind his back.

The hostage-taker had earlier fired shots and thrown an explosive package into the street in the center of Lutsk, a city of over 200,000 located some 400 kilometers (250 miles) from capital Kiev.

The man initially made contact with the police identifying himself as Maksym Plokhoy, a pseudonym which translates to "Bad Maxim", police said.

He was identified as Maksym Kryvosh, 44, who had previously spent around 10 years in prison on various charges.

President Zelensky apparently carried out one of the demands posted on the account when he recorded a Facebook video calling on people to watch the 2005 documentary film "Earthlings". Narrated by Joaquin Phoenix, the film chronicles the harsh treatment of animals at the hands of humans.

Zelensky spoke with Kryvosh after a phone was handed to him, deputy head of Zelensky's administration Kyrylo Tymoshenko told a briefing in Lutsk.

"He had a telephone conversation, speaking with him for 15 minutes, he convinced him to release three hostages," Tymoshenko said.

The president later deleted the short video from his account.

"Today loved ones can hug everybody who languished all day on the bus with a gun pointed at them," Zelensky wrote after the crisis was over, adding, "We did not lose a single person."

Interior Minister Arsen Avakov said Kryvosh came out of the bus following the negotiations.

"He really had a functioning pistol, an automatic rifle, he really had a grenade. There was a threat. But it's all in the past," Avakov said, according to AFP.

Police earlier said there were 20 hostages, but it turned out there were only 13.