Authorities Tuesday released video footage of the fatal shooting by a patrol officer of a 19-year-old man who advanced on San Diego Police Department personnel and pointed a BB pistol at them last week at San Ysidro Transit Center.

Mauricio Sanchez Ramos, address unknown, died on the evening of June 4 at the scene of the law enforcement shooting at the trolley station just north of the U.S.-Mexico border, according to SDPD public affairs.

The events that led to the fatal gunfire began shortly before 9 p.m., when police received a report of an armed man behaving erratically and foaming at the mouth on a light-rail tram approaching the depot in the 700 block of East San Ysidro Boulevard.

Surveillance video captured by a security system on the Blue Line trolley shows Ramos, a one-time Ramona resident, rocking back and forth stiffly in his seat before standing up, pulling the pellet gun from his waistband, holding the pistol in the air while jumping around and then pointing it directly at the mounted camera.

After the trolley arrived at the station, two San Diego police officers approached it, guns drawn. A body-worn camera worn by one them recorded images of Ramos sitting alone inside the tram, once again jerking forward and back in his seat.

After Ramos ignored repeated orders to put up his hands and exit the trolley, one of the patrolmen, SDPD Officer Ruben Berton, opened one of its doors. Ramos then stood up, pulled his gun and raised it in the direction of the officers, prompting Berton to retreat and fire about 10 rounds from his service pistol at the suspect.

Police subsequently determined that the gun Ramos had been carrying was a “Glock style” .177-caliber BB pistol, according to an SDPD statement.

City News Service contributed to this article.