A 31-year-old man attacked and tried to rape a woman on the counter of a Mr. Smoothie frozen yogurt store in a crowded commercial district in Rockville on Monday, Montgomery County police said. The woman fought back, kicked the man and hit an alarm button — causing the man to run away.

By day’s end, police had arrested Yera Basnueva, who has been charged with attempted first-degree­ rape and second-degree­ assault. Police said Basnueva’s past record includes charges of assault, indecent exposure and murder.

The incident began at ­9:23 a.m.­ inside the shop, which sits along Maryland Avenue in Rockville’s developed and relatively safe “Town Center” area, a walkable few blocks that brim with apartments, restaurants, bars and shops. A man walked in to the yogurt shop and struck up a conversation with an employee, introducing himself as “Yera.”

The man stayed for as long as 30 minutes and at one point went to use the bathroom, police said.

When the man came out, his pants were down and he “proceeded to grab the victim and push her on the counter next to the cash register,” detectives wrote in arrest papers.

The woman fought and kicked while the man ordered her to have sex with him and tried to pull down her pants, according to the arrest records. The alarm caused him to flee.

Detectives searched local police databases for the name “Yera,” found a mugshot of Yera Basnueva and showed it to the victim, along with photographs of other men. She picked out Basnueva, police said. Officers found him in the area of Valleywood Drive in Silver Spring, arrested him and took him to police headquarters.

“The suspect initially denied being in the Smoothie store but subsequently acknowledged being there and throwing a cup of coffee at the victim,” detective Dimitry Ruvin wrote in arrest papers. “The suspect reviewed a still photograph from the surveillance video and acknowledged it was him. The suspect’s criminal history includes arrest for assault, indecent exposure and first-degree murder.

Basnueva was being held Tuesday without bond in the Montgomery County jail, according to online court records. The records do not show a defense lawyer assigned to his case.

Jennifer Jenkins contributed to this report.