Kern County sheriff's deputies arrested a Bakersfield man after they say he attempted a home-invasion robbery in Oildale and beat a man with a hammer early Sunday.

Bobby Joe Smith III, 20, was arrested on suspicion of assault with a deadly weapon, robbery and burglary following the 2:10 a.m. incident at a house on Lincoln Avenue, the sheriff's department said in a news release Sunday.

Residents told deputies Smith came inside their home wearing a mask and gloves and demanded their computers and other electronics. He threatened them with a hammer, according to the release.

Family members said Smith then struck a male resident several times with the hammer. Another family member subdued and disarmed Smith by hitting him in the head with a baseball bat, the release said.

Family members then held Smith down until deputies arrived.

Smith was taken to Kern Medical Center for treatment of his injuries. The injured family member at the house was treated for bruises and cuts to his back, abdomen and legs from the hammer attack.