The antecedent of "this rock" has been debated for millennia.
There appear to be 4 possible antecedents--let's look at the preceding verses:
16 And Simon Peter answered and said, Thou art the Christ, the Son of
the living God.
17 And Jesus answered and said unto him, Blessed art
thou, Simon Bar-jona: for flesh and blood hath not revealed it unto
thee, but my Father which is in heaven.
18 And I say also unto thee,
That thou art Peter, and upon this rock I will build my church; and
the gates of hell shall not prevail against it.
- Jesus Himself (v 16)
- My Father (v 17)
- Peter (v 17)
- Revelation/testimony from God (v 17)
Definition of an antecedent from Oxford languages: "a word, phrase, clause, or sentence to which another word (especially a following relative pronoun) refers".
Petros vs petra
Peter in Greek is "petros", a masculine noun. The rock upon which the church will be built is "petra", a feminine noun, and the meanings of these words differ. Petra is a larger rock mass (see here) whereas petros is generally a smaller rock or pebble (see here).
As Caragounis points out:
[I]f the reference were intended to [be] Peter there were only two
alternatives available – which would have put the matter beyond
reasonable doubt. The first alternative would be: Σὺ εἷ Πέτροςκαὶ
ἐπὶ σὲ οἰκοδομήσω μου τὴν ἐκκλησίαν. There would still be a
word-play here, in as much as Πέτρος would have been understood to
refer to the well-known disciple, while at the same time the thought
of building would have reflected on the meaning of Peter’s name, i.e.,
the idea of a bedrock on which to erect the ἐκκλησία. The other
alternative, which is still better, would be: Σὺ εἷ ὁ Πέτρος ἐφ=
ᾧ οἰκοδομήσω μου τὴν ἐκκλησίαν. Ηere, the word Πέτρος would
have been understood doubly as the personal name of Jesus’
interlocutor and as the rock-foundation of the Church. In this case,
there would have been no doubt that the rock was Peter. That Matthew
chose to use Πέτρος and πέτρα, two different words, whose very
collocation marks a conscious juxtaposition, indicates clearly his
intention to contradistinguish the two terms
(see full discussion in Chrys C. Caragounis, Peter and the Rock (Berlin: Walter de Gruyter, 1990), 89-107) (see also abbreviated discussion here)
To those who believe on other grounds (e.g. patristic writings) that this is a reference to Peter this grammatical oddity has not been a deal-breaker, but it has led many to conclude Peter is likely not the antecedent.
A common argument is that the statement was originally made in Aramaic, in which there would have been no difference in gender or meaning – it would probably (this is debated) just be one word: kepha. Aramaic was spoken in this time and place and so this is possible.
However, this does leave a different matter unresolved: why when translating the statement into Greek did the author not simply use “petros” both times? To not do so introduced additional meaning (and unnecessary ambiguity) not found in the original. While it’s possible for an author/translator to take liberties with a source, it doesn’t do the authenticity (or authority) of the text any good to go down this route. (see here esp. footnotes 3 & 4)
Another interesting hypothesis is that Hebrew was spoken. (for evidence that Hebrew was a spoken language at this time, my thoughts here). As David Bivin has pointed out, the word play works in Hebrew too:
אַתָּה פֶּטְרוֹס וְעַל הַפֶּטְרָא הַזּוֹ אֶבְנֶה אֶת עֲדָתִי (atah
petros ve-al ha-petra ha-zo evneh et adati; You are Petros, and on
this petra I will build my community)
So at the very least the Aramaic hypothesis has some competition and probably should not be selected arbitrarily. As discussed on this site here, Jesus would have been familiar with Aramaic, Hebrew, and Greek.
(Quick aside for those who can't get enough of the linguistics discussion--see here yet another perspective--an argument from Porter that the conversation was originally in Greek)
Jesus is the rock
Jesus is certainly referred to as a rock in other places. He is the chief cornerstone in Ephesians 2:20, so Jesus is the preferred antecedent to many readers who do not accept Peter as the answer. This possibility is explored in greater depth in other responses.
In counter to this view, if He is indicating He is building His church upon Himself, what is the place/purpose of this passage in the story? (it is immediately followed by “I will give you the keys of the kingdom…”) Why does He need to tell them "my church is built on me" or “my church is my church?” And why not refer to Himself with “I” or “the Son of Man” as He usually does?
The word play would be unnecessary. Jesus would be telling Peter “blessed art thou”, “you’re just a little rock I can’t build on” and “I’m giving you the keys and the power to bind & loose” one after the other. The continuity and consistency appear to be lost.
None of these are knock-down arguments for or against a particular antecedent; if they were, I wouldn’t have had to start the post with the statement that this passage has been debated for millennia =).
Jesus, His Father, and Peter are all masculine—a feminine noun "petra" would be inappropriate as a name for any of them, so clearly a proper name is not intended (contra Petros which is being used as a proper name here). Each of these options is grammatically possible but the use of any as the antecedent is awkward, to say nothing of vague.
I will offer what I believe is the most grammatically simple solution. Since any of the singular masculine nouns could readily be referred to without ambiguity using a singular masculine pronoun, the antecedent probably is not a singular masculine noun. By process of elimination, revelation from God appears the most likely antecedent. It is the only one of the four options that can be referred to by “petra” but cannot be disambiguated by a pronoun.
This would mean that revelation, as Peter has received from the Father, is the process by which Jesus intends to guide His church.