SAN MATEO — A San Pablo man thought he was being a good Samaritan on Wednesday afternoon when he pulled a gun on a man he saw assault a woman near a busy downtown street corner, police said.

Instead, he was nearly shot by officers who rushed to Third Avenue and San Mateo Drive about 3:15 p.m., said San Mateo Deputy Police Chief Mike Callagy. The armed man, 23-year-old Ashley Viola, was still holding his .45-caliber pistol when police found and arrested him. No shots were fired.

“(Officers) have a split second to decide whether to shoot or not to shoot,” said Callagy. “All he had to do was call police.”

The trouble started when the would-be good Samaritan was driving on Third Avenue and saw a man push a 57-year-old San Mateo woman, almost knocking her down. The relationship between the pair was not clear. Witnesses said they watched the man get out of his vehicle and charge toward the pair with his gun drawn.

He stopped to talk to the woman, who pointed in the direction where the alleged attacker had gone.

The armed man went after her assailant and began yelling. “He was shouting, ‘Don’t you dare!'” said Lily Warren, who lives in Texas but is in the Bay Area visiting her sister. “I saw the gun. Everyone just scrambled.”

The first officer to arrive was a half of a block away when the confrontation began.

He approached Viola moments later near some newspaper racks on Third Avenue, just west of San Mateo Drive.

Viola gave up peacefully, but had his gun “in the ready fire position,” when confronted by officers, police said. He does not have a permit to carry a concealed weapon, Callagy said.

More than a dozen officers arrived on the scene within minutes, including a police dog, detectives and a traffic officer on a motorcycle. Some carried assault rifles. “The next thing I knew the police were there,” Warren, 38, recalled.

Crowds of onlookers collected at the intersection as officers roped off the area with yellow crime-scene tape. Viola was booked into San Mateo County jail on firearms charges. Police interviewed the man, who was not identified, alleged to have assaulted the 57-year-old woman. The case is being referred to the San Mateo County District Attorneys Office for review.

Contact Joshua Melvin at 650-348-4335.