HAYWARD — A second suspect was arrested early Friday in what sheriff’s officials now say was an attempted robbery and stabbing Thursday afternoon at a Jack-In-the Box restaurant in unincorporated Hayward.

The victim, an Oakland man, is in critical condition at a hospital with numerous internal injuries including a punctured lung, authorities said.

The suspect arrested Friday was identified as Alfredo Rubio, 56. His suspected accomplice, Adrian Lopez, 26, was arrested soon after the Thursday afternoon attack. The two Hayward men are being held without bail on suspicion of attempted murder, attempted robbery and assault with a deadly weapon, officials said.

Alameda County sheriff’s Sgt. Ray Kelly said the stabbing happened about 2:15 p.m. Thursday in the drive-through lane at the restaurant, located in the 18500 block of Mission Boulevard.

Kelly said the two suspects were lying in wait to rob someone in the line and targeted the Oakland man who was driving his car with his girlfriend as a passenger.

The suspects approached the driver’s side window and at least one of them simulated a gun and tried to rob the Oakland man, Kelly said. But the intended victim fought back and Kelly said both suspects stabbed him multiple times before running away.

Lopez was arrested within minutes in the 800 block of Paradise Boulevard.

Deputies used canines and a drone to search nearby streets and the shoreline of San Lorenzo Creek for the second suspect who turned out to be Rubio. He was able to elude capture Thursday as he had left the area on a bicycle he had hidden and had also changed his clothes, authorities said.

His fugitive status ended about 2 a.m. Friday when an alert deputy recognized him and arrested him in Hayward, Kelly said.