Tom is actually inside the jail when the lynch mob shows up to take and kill him. Among the potential lynchers is none other than Walter Cunningham, the man that Atticus had helped with legal troubles and accepted payment in nuts and produce as a favor. Tom's voice is heard coming from inside the jail once the mob is guilted into leaving by Scout Finch, whose innocent voice serves as a reminder to the men of all the good things that Atticus has given to Maycomb County. The men also have no desire to perpetrate a hate crime in the presence of a young female child. Throughout the intense scene, Tom is inside the jail.
In this chapter, the mob of men from Old Sarum come to lynch Tom Robinson. They are convinced that he is guilty of raping Mayella Ewell and they do not want to wait for anything like a trial. They are interested in just taking him and hanging him themselves.
The mob goes to the jail in downtown Maycomb. That is where they have their faceoff with Atticus that Scout finally breaks up.
If they are there to hang Robinson, it makes sense that he would be inside the jail while they are outside. That's exactly where he is. So Tom is in jail while Atticus faces the mob.
Here's the proof:
Shadows became substance as lights revealed solid shapes moving toward the jail door.
Atticus remained where he was. The men hid him from view.
"He in there, Mr. Finch?" a man said.
"He is," we heard Atticus answer, "and he's asleep. Don't wake him up."