After Chicago police staking out a Logan Square funeral home heard gunshots Tuesday, they spotted the alleged shooter hopping into a silver Honda Accord, leading them on a high-speed chase that ended with a car crash in Ravenswood, Cook County prosecutors said.

Josue Becerra, 24, fired the shots that left a 43-year-old man wounded outside Caribe Funeral Home, and also fired on officers as they gave chase, Assistant State’s Attorney Gino Betts said Friday at Becerra and his co-defendant Marcial Arriaga’s bond hearing.

Becerra was seen holding a gun as he got into the car with 26-year-old Arriaga, who sped off with police in pursuit, Betts said.

Arriaga allegedly blew through traffic lights and drove down one-way streets as he fled, crashing into three vehicles along the five-mile route. He ended up crashing in the 4400 block of North Western Avenue, Betts said.

Officers said during the chase, Becerra rolled down the window and pointed a gun at them. Then, they said they heard shots and saw Becerra toss the gun out of the car along the route. After the car crashed, Arriaga was pinned inside the wrecked Honda, but Becerra ran out before he was apprehended nearby.

The shooting victim was hit three times, and was taken to Illinois Masonic Medical Center in critical condition, police said.

Judge David Navarro ordered Becerra held on $100,000 bail Friday for attempted first-degree murder, aggravated assault and use of a weapon and aggravated battery.

Navarro set a $20,000 bail for Arriaga, who faces charges of aggravated fleeing and numerous traffic offenses.

Becerra was wearing an electronic monitoring anklet at the time of the shooting — a condition of his bond for a previous gun charge.

“....There’s no real explanation for someone on [electronic monitoring] to be outside their residence,” Navarro told Becerra.

The judge also chastised Arriaga for his alleged role as the getaway driver.

“There was every opportunity for that to have become a violent scene, and indeed, it ended with you pinned in the vehicle,” the judge said.