We have already learned that a korban Pesah that was taken out of the precincts of Jerusalem becomes invalid. This is also true for the meat of the Passover sacrifice (see Shmot 12:46). The Mishna on our daf teaches that if one of the limbs of the animal leaves the city it must be cut off and discarded, although the rest of the sacrifice is still kosher. In defining what is considered the boundary of the city, the Mishna deals with the agaf – the width of the entranceway itself. According to the Mishna, from the agaf and inwards is considered the inside of the city; from the agaf and outwards is considered outside the city.
The Gemara questions the mishna: This matter itself is difficult; the mishna itself contains an internal contradiction. At first you said that the space from the doorway inward is considered as though it is inside, which indicates that the space of the doorway itself is like the outside. Now you say the latter clause of the mishna’s ruling, which states that from the doorway outward is considered as though it is outside, which indicates that the doorway itself is considered as though it is inside.
The Gemara answers: It is not difficult, as one can explain that these two statements are referring to different situations: Here, in the first clause of the mishna’s ruling, it is referring to the gates of the Temple courtyard, where the inside of the doorways were considered as though they were inside the courtyard and had the sanctity of the courtyard itself. There, in the latter clause, it is discussing the gates of Jerusalem, where the insides of the gates were considered like the outside and did not have the sanctity of Jerusalem.
Rabbi Shmuel bar Rav Yitzhak explains that the gates of the city were not given the kedusha – the holiness – of the city, out of concern for the metzora’im, the lepers, who make use of the doorways for protection against the elements.
We have already learned that people suffering from tzara’at – what is usually translated as leprosy – were obligated to remain outside the three encampments when the Jewish people were in the desert, and correspondingly outside of the city of Jerusalem (and, according to some opinions, all walled cities in Israel), until they are healed. Such a person standing outside of the city in the rain or on a hot, sunny day would be unable to find any protection from the elements if he could not duck into the doorway of the city. Out of consideration to these people the Sages chose not to give kedusha to the agaf of the city.