The attack occurred around 9:05 a.m. at the Oakridge Mall on Thornwood Drive, police said.
Police said the woman struck the victim, a man she did not know, twice in the head then threw the hammer at him when he fled.
The victim was transported to a hospital with injuries that were not considered life-threatening.
Officers arrested the woman and booked her into Santa Clara County Jail, where she underwent a psychiatric evaluation.
Police said the attack was unprovoked and that the woman may suffer from a mental illness.