A San Jose man accused of trying to sexually assault a woman and a 13-year-old girl was identified with the help of his landlord, who recognized him from surveillance video, a prosecutor said Tuesday.

Mohammad Khaliqi, 31, of San Jose made his first appearance Tuesday in Santa Clara County Superior Court but did not enter a plea to charges of attempted sexual assault during a burglary, false imprisonment and assault with intent to commit a felony. If convicted, he could face up to life in prison.

Khaliqi is being held without bail at County Jail in San Jose.

Outside court, prosecutor Bret Wasley told reporters that Khaliqi’s landlord saw surveillance video of the defendant and came forward to San Jose police.

“The person who he rented a room from saw the videos that was on TV and said, ‘That looks like this guy,’” Wasley said.

Khaliqi rented a room on Troy Drive, within walking distance of the two attacks, but left his home “in the middle of the night” and went to a relative’s home in San Leandro, police said. He altered his appearance after his picture and surveillance video of his alleged attack on the teenage girl was widely circulated on television and on social media, authorities said.

“It’s scary, I mean you all saw the video,” Wasley said. “This is a terrifying case. These are the actions of a brazen predator.”

He added, “He is acting on impulse and grabbing random strangers and trying to rape them, and I can’t think of anything more scary than that.”

The most recent incident happened about 4 p.m. May 5, when the suspect followed a 13-year-old girl as she walked from school to her home on the 4000 block of Rio Vista Avenue, police said.

As the girl unlocked her front door, the man walked up to her and spoke with her. Feeling uncomfortable, she went inside her home, but home surveillance video shows the man forcing his way inside and pushing her up against a wall. She fought back, and he left, authorities said.

About 12:55 p.m. April 2, the man followed a 28-year-old woman into the restroom at Mitsuwa Market at 675 Saratoga Ave. and tried to attack her before leaving, police said.

Henry K. Lee is a San Francisco Chronicle staff writer. E-mail: hlee@sfchronicle.com Twitter: @henryklee