SAN JOSE — A minor flap over an unpaid light-rail fare almost became a deadly affair Friday night after a man allegedly exchanged gunfire with an officer downtown and later tried to run down another officer with a carjacked vehicle in South San Jose, according to police.

That such an everyday police task swiftly devolved into near-disaster evoked still-raw feelings in the region’s consciousness from the July 22 slaying of Hayward police Sgt. Scott Lunger during a traffic stop. And San Jose is not far removed from the March 24 death of Officer Michael Johnson, killed by a suicidal gunman lying in wait as he responded to a 911 call.

“It goes to show the dangers officers face every day,” San Jose police spokesman Sgt. Enrique Garcia said. “You don’t know who you’re dealing with in every contact. Officers have to use extreme caution every time.”

That message was given more gravity this past week when San Jose police began saturating parts of downtown and East San Jose with additional officers, working overtime, to quell a spike in violence over the past month.

In Friday’s night’s incident, the suspect, whose name was not immediately released, was wanted on a warrant for violating probation stemming from a burglary conviction, Garcia said. But he noted that the officers who approached him did not know that.

“Unbeknownst to them, this guy is a wanted criminal and armed with a firearm,” Garcia said. “He had an advantage over the officers.”

The violent sequence Friday began about 11:20 p.m. with an encounter between two SJPD patrol officers and a group of men on a light-rail train heading through downtown. The officers approached the group and asked if they had paid their fares.

Several members of the group admitted they had not, Garcia said, and the officers advised them to get fare tickets at the next stop, at San Carlos Street and South Almaden Boulevard. Everyone got out of the train, and most of the group complied with the officers’ orders and went over to a nearby fare machine.

But one man in the group instead walked in the opposite direction, prompting the officers to confront him and remind him to pay his fare. Police say that’s when, astonishingly, the man announced that he was armed and fled north along Almaden.

“The suspect says, ‘I have a gun,’ and takes off running, and the officers give chase,” Garcia said.

While running from the officers, Garcia said the suspect at one point turned around, pulled out a handgun and fired at them, but did not hit anyone. One officer returned fire but also missed.

The suspect then reportedly failed to commandeer a vehicle on the street, and made his way inside a parking garage at Park Avenue and Almaden, where he carjacked a motorist and drove away. By that point other San Jose officers were pursuing the stolen vehicle, which got onto Highway 101, which prompted the California Highway Patrol to join the chase.

He made it to South San Jose, where at Carling Court and Edenview Drive the suspect tried to “drive into an officer,” police said, prompting the officer to open fire. The suspect was not hit and drove off, where about four miles west he crashed into a vehicle at Branham Lane and Almaden Expressway.

The man tried to run away from the wreck but was caught and arrested. He was taken to the hospital to be treated for moderate injuries, as were the two occupants of the vehicle he hit. The carjacking victim from downtown was not injured.

Once he is cleared from the hospital, the suspect was expected to be booked into Santa Clara County Jail on suspicion of attempted murder of a peace officer, carjacking, evading arrest and the probation violation.

The two officers who fired their weapons have been placed on paid administrative leave as police launch an investigation monitored by the Santa Clara County District Attorney’s Office, which is routine in officer-involved shootings.

Contact Robert Salonga at 408-920-5002. Follow him at Twitter.com/robertsalonga.