Riolu's Egg was originally found in the Sinnoh region. Despite being passed from one Day Care worker to another for a long time, it seemed unwilling to hatch. Eventually, it came under the care of the Nurse Joy working in Vermilion City.
While Ash battled Hashiba, the Egg sensed the strong Aura emitted by the former and reacted to it. Ash also felt the Egg calling for him. While Pikachu was being treated at the Pokémon Center, Ash followed the call to the room where the Egg was being kept. When the Egg reacted to Ash's presence by rolling towards him, Nurse Joy decided to entrust its care to him.
The following night, the Egg hatched into a Riolu, who instantly fled from the Sakuragi Institute and started attacking various wild Pokémon, although all of them were too strong for it. Ash finally caught up to Riolu as it was getting attacked by an Onix. During the battle against the Rock Snake Pokémon, Riolu was impressed by Ash's Aura. With both Pikachu and Riolu attacking Onix, Ash was soon able to drive it away, and then, he took Riolu to the Pokémon Center to be healed. After Nurse Joy treated Riolu, it expressed willingness to be caught by Ash, which he agreed to.
Riolu, like every other member of its species, responds to Aura, and, as such, developed a subconscious connection to Ash before it even hatched. After hatching, it displayed a very headstrong personality, attacking wild Pokémon and even Ash, as if it had something to prove. Despite being a baby Pokémon, it displays dislike towards being cared for and generally seems very independent.