A train operator at the BNSF Richmond Railyard discovered the injured bicyclist shortly after 3 a.m., Richmond police said.
The 43-year-old man was standing near the train tracks with his bicycle when the engineer noticed him, and managed to stop the train, thinking he wanted to cross the tracks.
The engineer thought the long freight train would keep the bicyclist waiting for a long time.
But when he stopped the train, he discovered the bicyclist was bleeding, and he said he had been shot.
When police arrived, the bicyclist told them that he had been walking on the train tracks between West Cutting Boulevard and West Ohio Boulevard when someone sighted him with a laser from a nearby rooftop and opened fire.
The bicyclist fled the area on foot.
He was taken to a nearby hospital for treatment, but his injuries were not life threatening, police said.
Police cordoned off the area and searched for the shooter but were not able to locate any suspects.