Jesus looked at the disciples to make sure they were listening. Then he rebuked Peter acknowleding that Satan was speaking through him.
This happened because Peter did not grasp and so was not in agreement with the things of the HolySpirit. Rather, he was considering only the flesh.