At the time of Christ, Judaism was a religio licita (permitted religion); as such there were legal concessions made to the Jewish people. For example, "Jews might gather freely in thiasoi, observe the Sabbath and the Jewish festivals, send money to the Temple in Jerusalem, and enjoy autonomy in their communal affairs. Jews were also absolved from compulsory enrollment in the Roman military."
In particular, the Romans gave a measure of autonomy in how the Temple affairs were governed. The existence of the Sanhedrin as an official body to meet and pass judgment on matters in their jurisdiction is an example of their legal standing.
Earlier, John noted the presence of "law enforcement" agents under the direction of the chief priests:
The Pharisees heard the crowd muttering these things about him, and the chief priests and Pharisees sent officers to arrest him. (John 7:32) [ESV]
This same condition is found throughout the book of Acts, where the disciples and Apostles in the Temple precincts are arrested, beaten, and in Stephen's case, stoned to death under the authority of the chief priests and the Sanhedrin. This is the point John is making.
The fundamental difference between the two situations is the legal situation: in the Temple, a Jewish person was subject to the chief priests who had the ability and resources to enforce their rules and decisions. They had official "police," a prison, a system for trials and for carrying out their decisions; outside of Jerusalem, they had less power.
Those sent to arrest Jesus decided not to follow their orders:
The officers then came to the chief priests and Pharisees, who said to them, “Why did you not bring him?” The officers answered, “No one ever spoke like this man!” (7:45-46)
However, after saying those who were against Him were children of the devil, there was a different response:
So they picked up stones to throw at him, but Jesus hid himself and went out of the temple. (8:59)
The earlier favor Jesus had with the officers and others undoubtedly evaporated after He accused them of being children of the devil. In order for Jesus to die by crucifixion and not by a quasilegal stoning, it was necessary for him to hide from the officials who had real authority to legally arrest Him and leave the Temple, the location where their authority was greatest.