Marty Preston is an eleven year old boy who likes to walk the backwoods behind his house. On one of his walks, Marty finds a beagle cowering in the bushes so he goes over to the dog and pets him. The dog seems shy but receptive to Marty although he doesn't respond to Marty's call of "Here, boy!" Thinking that the skinny pup got out from a nearby house and will probably make his way back there, Marty keeps walking but when he turns he sees that the dog is following him. When he walks, the dog follows. When he stops, so does the dog. It's obvious that the beagle is not well cares for and Marty wants to help but he struggles communicating with him until he thinks to whistle; this works like magic and the dog responds, licking Marty's face and trotting along by his side. When Marty goes home the dog follows him. He names him Shiloh, after the place where he found him.
Despite Marty's pleas, his parents make him turn the dog back over to Judd Travers, whom Marty doesn't like at all. Judd is cruel to his animals. He keeps them chained up outside and deliberately keeps them hungry so that they will be better hunters. Shiloh is obviously scared of Travers and Marty feels like he has let him down.
Marty cannot get Shiloh out of his mind and is delighted to see him again when the dog turns up at the house when the rest of the Preston family are out. Marty promises Shiloh never to let Judd Travers take him back. He sets about building a pen where he can keep Shiloh in secret, making sure there is both shade and shelter in case of rain. He decides to start eating only half of his dinner and tells his mother he is too full to finish it but gets hungry again later, so that she keeps it for him without using the leftovers for soup. Marty is getting hungrier himself with only half his usual food but Shiloh is his priority. He pays a visit to the corner store where he asks to buy any food that is spoiled, knowing it will be cheaper. He is able to buy some cheese with a mouldy rind that he cuts off, frankfurter sausages and some sour cream. It's a little rich for Shiloh but he gulps it down, and even after a couple of days seems to be gaining a little weight. His ribs don't protrude anymore and there's more flesh on them. Marty's father is amazed to find food for him to take inside most of the mailboxes on his delivery route; clearly word has spread that the Preston's need food, and Marty knows his parents would be mortified if they realized Marty had given the town the impression that they were only able to afford spoiled groceries.
Marty loves to lie on the grass with Shiloh lying on top of him but opens his eyes to find his mother staring angrily down at him. Suspicious at his food hoarding after lunch she follows him up to the hill and finds out his secret. When Marty tells her Travers abuses Shiloh she is sympathetic but gives Marty twenty-four hours to come up with a plan because she is not going to keep Shiloh a secret from Marty's dad after that. Marty tries desperately to come up with a plan but cannot think of anything. That night the entire household is awoken by crying and yelping outside. Marty realizes that something has happenned to Shiloh and races outside but his father beats him to it and they find a neighbor's German shepherd with Shiloh's blood around his mouth. Shiloh is badly injured and barely breathing. Marty's father is furious with him for the deception but anxious to help save Shiloh's life so he drives Shiloh and Marty to see Dr Murphy; he is not a veterinarian but promises to use his medical skills to best help save Shiloh.
Marty is frustrated with his father for making him return Shiloh to Judd when he is better, knowing that Judd will abuse him more. He manages to buy some time and persuades his father to let him keep Shiloh whilst he is recovering, but knows he needs to come up with a longer term plan. When Doc Murphy brings Shiloh back to their house as he bounced back surprisingly quickly. Unfortunately a patient saw Shiloh at the doctors office and told Judd Travers who has been asking all over town where his missing hunting beagle and Judd arrives at their house to take Shiloh back. He is furious that Shiloh is injured and actually agrees that he should recuperate at the Preston home as he feels like they owe it to him to make his dog better. He gives them until Sunday to return Shiloh. Seeing how terrified Shiloh is of Judd, Marty's mother asks Judd if they can buy him. Judd refuses.
By Sunday, everyone is attached to Shiloh and nobody wants him to leave. Early on Sunday before anyone else gets up, Marty walks to Travers' house to confront him and tell him that he will have to fight him to get his dog back. As he walks he sees Judd deliberately shoot a deer and realizes this will be his bargaining tool; he tells Judd that if he lets him keep Shiloh, Marty won't tell anyone about his shooting a deer out of season. Judd is angry but agrees to sell Shiloh to Marty for forty dollars, and Marty will have to pay this by working for Judd on weekdays for two hours a day, earning two dollars an hour. Judd writes this down and signs it.
Marty quickly realizes that Judd is going to work him to exhaustion at jobs that a grown man would struggle with. One day Judd tells him their agreement was not valid since there were no witnesses. Marty is scared he may be right but works to fulfill the agreement anyway. At the end of the two weeks, Judd almost has come to respect Marty. Shiloh is Marty's and the Preston's have a new family member that they all adore.