SAN MATEO — A man arrested late Sunday in connection with showing a replica firearm at two shopping malls pleaded no-contest in 2011 to impersonating a police officer, authorities said.

Shortly after 3 p.m. police responded to the Hillsdale Shopping Center for multiple reports of a man acting strangely with a firearm in his waistband. Witnesses told officers the man had brandished what appeared to be a black handgun while telling people he was an undercover police officer.

After learning the man had left the area, officers searched the shopping center and worked with security staff to find and broadcast an image of the man from surveillance camera footage.

Calls in response helped police identify him as Allen Grabovetsky, 27, of San Mateo, police said.

Just before 6 p.m., police received a second call about a similar suspect at the Laurelwood Shopping Center. When officers arrived moments later, witnesses said the man had been there an hour before, claiming to be a member of the military and waving a black handgun, according to police.

Soon, other witnesses told police the man was at a nearby shop, and officers found and took him into custody.

Visitors to both shopping centers were able to identify Grabovetsky, and a search of his home found a black-colored replica handgun and clothing, police said.

He was later arrested and booked into Maguire county jail late Sunday on suspicion of impersonating a police officer and brandishing a replica firearm. He was held on $20,000 bail Monday and faces a 1:30 p.m. Tuesday hearing, according to a county records check.

According to previous reports, Grabovetsky was arrested in December 2010 after police learned he had been driving a pickup truck with police lights and pulling drivers over for allegedly speeding.

Later that month, he was also arrested for attempting to sell marijuana to a person at a Caltrain station, and prosecutors learned of additional text-messaging of violent threats to a friend.

In a July 2011 plea bargain, Grabovetsky pleaded no contest to felony impersonation of a peace officer, possession of marijuana for sale and stalking, as well as misdemeanor annoying of a child, requiring lifetime sex-offender registration.

Contact George Kelly at 408-859-5180.