The next day he saw Jesus coming toward him, and said, "Behold, the Lamb of God, who takes away the sin of the world! This is he of whom I said, 'After me comes a man who ranks before me, because he was before me.' I myself did not know him, but for this purpose I came baptizing with water, that he might be revealed to Israel. John 1:29–31
How could John (the Apostle) claim John (the Baptist) did not know Jesus? Especially in light of Matthew 3:14:
John would have prevented him, saying, "I need to be baptized by you, and do you come to me?"
Going even further back, how could John not know Jesus in light of Luke 1:39–45:
In those days Mary arose and went with haste into the hill country, to a town in Judah, and she entered the house of Zechariah and greeted Elizabeth. And when Elizabeth heard the greeting of Mary, the baby leaped in her womb. And Elizabeth was filled with the Holy Spirit, and she exclaimed with a loud cry, "Blessed are you among women, and blessed is the fruit of your womb! And why is this granted to me that the mother of my Lord should come to me? For behold, when the sound of your greeting came to my ears, the baby in my womb leaped for joy.
These two should have known one another from their youth in a family-driven culture. Harmonizations of these accounts, claiming John lived a solitary life or the families "lost touch" while Jesus' family was in Egypt, seem to fall flat in the face of the culture.
Instead of looking for an explanation by harmonizing timetables, it is better to return to why John wrote his gospel:
Now Jesus did many other signs in the presence of the disciples, which are not written in this book; but these are written so that you may believe that Jesus is the Christ, the Son of God, and that by believing you may have life in his name. John 20:31–31
To have eternal life, you must believe. To believe, you must know. John returns to this theme of knowing constantly:
He was in the world, and the world was made through him, yet the world did not know him. John 1:10
Nathanael said to him, "How do you know me?" John 1:48
Rabbi, we know that you are a teacher come from God, for no one can do these signs that you do unless God is with him. John 3:2
You worship what you do not know; we worship what we know, for salvation is from the Jews. John 4:22
But we know where this man comes from, and when the Christ appears, no one will know where he comes from. John 7:27
Lord, we do not know where you are going. How can we know the way? John 14:5
John divides the world between those who know differently about Jesus. In the modern world, we describe these kinds of knowing as "head" and "heart" knowledge, but what do these even mean? The division, given the modern definition of "heart," is one is emotional while the other is intellectual. If this is the division we seek, it is not found in the Scriptures anywhere—nor helpful.
What kind of knowledge is John using here?
We can begin by excluding the concept of knowing as an intimate experience or a technique over another—neither of these fits in this situation.
We can assume John knows Jesus in the sense of knowing who Jesus is. He has lived in the same extended family for some 30 years.
We can assume John knows Jesus is the Messiah. What we cannot assume is that John connects Jesus as the Messiah with spiritual salvation rather than some physical or military salvation for Israel as a nation.
In other words, we can read John's statement something like this:
I know Jesus, and I know Jesus is the Messiah, but I did not connect Jesus the Messiah to being the literal Son of God in whom I must place my faith.
Reading John 1:29–31 in this way connects all the dots and makes sense of the entire narrative. John knows Jesus is the Messiah, and therefore, Jesus should be baptizing him rather than John baptizing Jesus. In the event of the baptism itself, however, or perhaps through the prompting of the Spirit, John discovers Jesus is the very Son of God, to be worshiped. John discovers Jesus is not just another person but rather the correct object of faith for salvation.
John has faith in the Father, which he knows as Yahweh, the God of Israel. John now sees that standing before him is the Son, who is one with the Father—the very God of Israel in living flesh. He knew Jesus as a man before this. Now, he knows Jesus as God.
This view of knowing goes beyond our "mind/heart" dichotomy of our modern world. John discovers something new and decides to place his faith in the Son because of that new knowledge. This knowing combines the mind and the will, impacting the person's very core.