Videos captured from numerous bystanders show Hermawan holding the knife at Oktaviani, who is cradling her sleeping baby. Visibly agitated, Hermawan yells at the growing crowd and orders them to disperse so he can make his getaway.
While some members of the crowd try to talk the man out of violence, others heckle him; "Be patient, you nut case," and "have you not eaten or something?"
Others called for him to be burned.
In the footage, officer Sunaryanto can be seen firing a shot at Hermawan, close range, hitting his right arm. Chaos ensues, and Hermawan is beaten by an angry mob.
"The culprit, however, refused to give in, even though he was panicky. After about half an hour of negotiation, the police decided to shoot him in his right arm," the head of the East Jakarta Police criminal unit, Sapta Maulana, told The Jakarta Post.
Oktaviani and her baby managed to escape safely, with mum suffering a small injury to her neck from the knife.
According to local reports, Hermawan was taken to National Police hospital where he was treated for his gunshot wound. He admitted he "often mugs women and uses the money to feed his gambling addiction".
Authorities said officer Sunaryanto will receive an award for his bravery.