Which earliest sources does Christianity posses that claim that apostle John spent the last years of his life in Ephesus?
Revelation 1:9 explicitly states that John was on the island of Patmos when he wrote revelation:
I, John, your brother and companion in the suffering and kingdom and patient endurance that are ours in Jesus, was on the island of Patmos because of the word of God and the testimony of Jesus.
That he would have been exiled there is common:
"Early tradition says that John was banished to Patmos by the Roman authorities. This tradition is credible because banishment was a common punishment used during the Imperial period for a number of offenses. Among such offenses were the practices of magic and astrology. Prophecy was viewed by the Romans as belonging to the same category, whether Pagan, Jewish, or Christian. Prophecy with political implications, like that expressed by John in the book of Revelation, would have been perceived as a threat to Roman political power and order. Three of the islands in the Sporades were places where political offenders were banished." (Pliny Natural History 4.69-70; Tacitus Annals 4.30)
Patmos is an island very close to the city of Ephesus, the major port city of the day. Indeed, Revelation 2 - 3 is a series of letters to the 7 cities in Western Turkey, and Ephesus is by far the largest of them. This is not surprising, since Rome pretty much cleared Jerusalem of Jews in 70AD (actually completely destroyed Jerusalem in 125AD!) thus resulting in a diaspora that moved many of the writers to Western Turkey and Galatia. Indeed - every one of the Epistles written to a city or region in Turkey or Greece.
Were we to receive word that a certain person was familiar with the Bronx, Manhattan, Newark, Hoboken, and we have written correspondance to them where he claims to be at Hsing Hsing prison - especially absent any transportation - it would not at all be unreasonable to assume he is from New York.
When tradition thus states that John was living in the biggest city of the area, and we have written correspndance that shows how close he was, it's a really safe bet.
The earliest written tradition placing John in Ephesus comes from Irenaeus, Against Heresies, book 3, chapter 3, section 4. During an explanation of how the apostles passed on teachings to their chosen successors, Irenaeus says:
There are also those who heard from him [Polycarp] that John, the disciple of the Lord, going to bathe at Ephesus, and perceiving Cerinthus within, rushed out of the bath-house without bathing, exclaiming, “Let us fly, lest even the bath-house fall down, because Cerinthus, the enemy of the truth, is within.”
Irenaeus lived and wrote in the late 2nd century, but as a young man he had met Polycarp and been taught by him. Polycarp, in turn, is said by Tertullian (Prescription against Heretics, chapter 32) to have been appointed Bishop of Smyrna by John.
It is just a tradition that John the Revelator is also John the Apostle whom Jesus loved. Nothing inside the word specifically says who is John the Revelator. In a similar fashion the epistle titled James is not thought to be written by either James the Apostle of the Lamb. It is also tradition that John lived at Ephesus. So Revelation itself is not a good choice for this tradition. The oldest tradition I could find but was not qualified for the word of God and also is not used as cannon and probably is just made up and is definitely gnostic is the acts of John.
Irenaeus is the source of the idea the John lived in Ephesus. Irenaeus was born in 130 - at least 30 years after John died. He wrote Against Heresies in about 180 - it is this work where he makes the claim.
John's living in Ephesus, if Irenaeus is correct, would have to occur AFTER the "coming of the Son of Man". Because before the "coming of the Son of Man" John was forbidden to preach in Samaria or places of the Gentiles.
The names of the twelve apostles are these: first, Simon, who is called Peter, and Andrew his brother; James the son of Zebedee, and John his brother; (3) Philip and Bartholomew; Thomas and Matthew the tax collector; James the son of Alphaeus, and Thaddaeus; (4) Simon the Zealot, and Judas Iscariot, who betrayed him. (5) These twelve Jesus sent out, instructing them, "Go nowhere among the Gentiles and enter no town of the Samaritans, (6) but go rather to the lost sheep of the house of Israel. ... Mat 10:23 When they persecute you in one town, flee to the next, for truly, I say to you, you will not have gone through all the towns of Israel before the Son of Man comes.
Mat 10:2-6 - ESV
Therefore, his living in Ephesus that Irenaeus speaks of would be sometime in the last portion of the 1st Century.
The Son of Man was Jesus, he came in power of the Resurrection on the 17th of Nisan, 30 A.D. and the gospel had not been preached in all the towns of Israel before his resurrection. There is no proof, only conjecture that John was in Ephesus, though it is possible since the apostles would’ve left Jerusalem during the siege of Titus, probably John was the only remaining of the 12 disciples. Mary would not have traveled to Ephesus considering she would’ve been around 84 years old at that time. Its very likely that she was deceased and buried in Nazareth many years prior.