The narrative jumps ahead two months to a Saturday evening in October. Bathsheba and Troy are traveling up the steep Yarbury Hill, coming from Casterbridge to Weatherbury. They have been at the markets. Bathsheba rides in the gig, while Troy walks alongside her.
This is the first glimpse we have of the two of them alone together, and the marriage does not seem to be going well. Bathsheba complains about all the money Troy has lost at the horse races. Troy has bought his discharge from the army and is dressed as a fashionable farmer. As they argue, Bathsheba begins to cry, and Troy tells her, "You have lost all the pluck and sauciness you formerly had," implying that he regrets having married her.
As they proceed, they pass a woman who asks Troy the way to Casterbridge. When he replies, she utters a cry and falls down, recognizing his voice: The woman is Fanny. Bathsheba is alarmed, but Troy makes the horse carry her on up the hill while he stays and talks to Fanny. We learn that he has had no idea where to reach her, and that she was afraid to write to him. He realizes that she needs money, and agrees to meet her two days from then at Casterbridge. When he catches up with Bathsheba she is suspicious, accusing him of knowing the woman's name and not telling her. Troy denies all acquaintance with the woman.
Chapter 40 tells the extraordinary story of Fanny's difficult walk to Casterbridge that night. We know it is Fanny, but the narrator identifies her only as "the woman." Stumbling weakly, she comes to a haystack and falls asleep beneath it. Upon waking, she thinks she may be dead by the time she is to meet Troy. She persuades herself to go on by counting the milestones, frequently pausing. She takes two sticks to use as crutches but falls. A dog appears, and she leans on him the rest of the way. Finally, near morning, she reaches Casterbridge.
In the meantime, Bathsheba and Troy have been sullenly avoiding all conversation. On Sunday evening, Troy asks her for 20 pounds, saying that he needs it badly. He eventually admits that it is not for horse racing, but he will not tell her what it is for. As they argue she notices a curl of yellow hair in his watch and asks him about it. He explains that it belongs to "a young woman I was going to marry before I knew you." After she demands that he burn it and he refuses, Bathsheba bursts into great sobs, hating herself for being so weak as to fall for Troy.
The next day as she rides around the farm, she sees the laborer Joseph Poorgrass talking to Gabriel and Boldwood. Poorgrass then approaches her with the news that Fanny Robin is dead from an unknown cause. As the chapter continues, Bathsheba begins to suspect that Fanny Robin is the woman Troy had loved and that she has died giving birth to a child. She questions Poorgrass and Liddy to test her suspicions. She offers to bury Fanny, as Fanny worked for Bathsheba's uncle, and sends Poorgrass to collect the body.