Shiloh is written in the first person point of view, revealing the thoughts and feelings of the determined and compassionate protagonist, Marty Preston. The novel begins when a young beagle follows 11-year-old Marty as he takes a walk up in the hills on the road past the old Shiloh schoolhouse near Friendly, West Virginia. Because the dog is "slinking down, . . . tail between his legs like he's hardly got the right to breathe" and backing off and cringing when Marty puts out his hand, he is sure the dog's owner is abusing him. Marty feels protective of the dog, and names him Shiloh.
Marty's father thinks the dog belongs to Judd Travers, who recently got another hunting dog. Marty doesn't like Judd or trust him. Marty saw Judd cheat Mr. Wallace in the corner store, Marty knows that Judd kills deer out of season, and he hates that Judd chews tobacco and tries to spit it close to people he doesn't like. When Marty's father takes him to Judd's trailer to return Shiloh, Marty sees Judd kick Shiloh and pleads with Judd to stop kicking the dog.
Marty can't stop thinking about Shiloh. He decides that he has to buy Shiloh from Judd. Unfortunately, there aren't very many jobs in Friendly for a boy his age. Marty starts collecting cans and bottles to try to make some money, but realizes it will take him forever to raise enough money to buy Shiloh. He also thinks about what he will feed Shiloh. Because his family is sending money to help care for his Grandma Preston, the family doesn't have any extra money to spend on dog food.
Before long, Shiloh runs away from Judd again and ends up at Marty's house. This time, Marty hides Shiloh in a makeshift pen just off the path that leads up the hill behind his house. He makes sure Shiloh has water and protection from the weather. Marty becomes attached to Shiloh as he continues to care for him — taking Shiloh on long walks, playing with him, and feeding him whatever he can manage to save from his own meals. Marty even swallows his pride and asks Mr. Wallace at the corner store for old food that he can buy cheap, just so Shiloh won't go hungry.
Marty's Ma discovers Marty's secret when she finds Marty with Shiloh in the pen one evening. She agrees to keep his secret until the next day, giving him time to decide what to do about Shiloh. That night, a German shepherd jumps into Shiloh's pen and attacks him. Marty's Dad takes Shiloh to Doc Murphy. Even though Doc Murphy is not a vet, he agrees to help Shiloh. Marty's Dad agrees to let him keep Shiloh until Shiloh is well, and then Shiloh will have to go back to Judd. Marty feels guilty. He feels it was his fault Shiloh was hurt because he didn't make the pen tall enough. He also feels relieved because his secret is out in the open and he has time to figure out how he can keep Shiloh.
The next day, Doc Murphy shows up with Shiloh. Marty's Ma tells Marty to get a box and put it in the kitchen for Shiloh. As Shiloh's condition improves, and he is able to hobble about, Marty's family slowly but surely falls in love with him. Marty is more determined than ever to keep Shiloh. He feels that his only option is to talk directly to Judd.
Early in the morning on the day Shiloh is to be returned to Judd, Marty cuts through the woods on his way to Judd's trailer. On his way, he catches Judd shooting a deer out of season. Marty knows that if the Warden finds out, Judd will be fined for shooting the deer. Marty confronts Judd, and, thinking quickly, he makes a bargain with Judd. He agrees to be silent about Judd shooting the doe in exchange for Shiloh. Marty also agrees to work for Judd twenty hours for two dollars an hour, in order to pay for Shiloh.
The work Marty does for Judd is difficult, backbreaking work; however, he attempts to do his best. During the time he works for Judd, Marty gains understanding about Judd and feels almost sorry for him. Marty can finally see Judd as a person who doesn't know how to care about other people or animals. Marty feels proud of himself for keeping up his end of their bargain in spite of the obstacles that Judd has put in his way. On the last day that Marty works for Judd, Judd gives Marty a collar for Shiloh and tells him, "you got yourself a dog." Marty's family celebrates the fact that Shiloh belongs to them and Marty realizes that "nothing is as simple as you guess."