The Gospel of Luke’s story of the Annunciation (Luke 1:26-38) assumes that Jesus had no biological father. Matthew’s Gospel asserts that Joseph did not father Jesus (Matt 1:18-25), but it is far from clear that Matthew believed in the virgin birth (despite the nearly universal use of “virgin” to translate, accurately or not, Matt 1:23). Whatever Matthew thought he knew about Jesus’ biological origins, he is careful to narrate that Joseph obeys the angel’s directives to go through with his marriage to Mary and to name Jesus (Matt 1:24-25). By doing so, Joseph accepts Jesus as his legal son, thus enabling him to inherit Joseph’s genealogy and to be rightfully considered a descendant of King David. Luke, like Matthew, asserts Jesus’ Davidic ancestry (Luke 1:32) and traces it through Joseph, albeit via a genealogy (Luke 3:23-38) that contradicts Matthew’s. Unlike Matthew, Luke has no explanation for how Joseph’s genealogy can apply to Jesus, who is not his biological son.
Mark’s Gospel has no interest in the birth of Jesus. Neither does the Gospel of John, which has the disciple Philip describe Jesus as the son of Joseph (John 1:45), with no hint from the author that this description is mistaken or inadequate.
Of the four Gospels then, only Matthew shows any interest in the question of whether Jesus was legitimate, and Matthew is quick to clarify that Joseph “adopted” Jesus and so made him his legitimate heir.
A Gospel passage that might seem to reflect accusations of Jesus’ illegitimacy is Mark 6:3, in which the people of Nazareth refer to Jesus as “the son of Mary.” Is this their insinuation that his father is unknown, or does it imply only that Jesus was the son of a widow? We just don’t know whether “son of Mary” would have been derogatory in first-century usage. In the context of Mark 6:1-6, however, no insult seems intended. The upshot of the six rhetorical questions in Mark 6:2-3 is to contrast Jesus’ new fame with his ordinary roots. Therefore, the way Mark uses “son of Mary” does not indicate that he understands it as a slur on Jesus’ legitimacy.
In an especially rancorous exchange in the Gospel of John, “the Jews” retort to Jesus, “We’re not bastards!” (John 8:41). (“Bastards” captures the insulting tone better than the more polite translation, “illegitimate.”) The syntax of the assertion puts the emphasis on the “we,” and thus implies, “We’re not bastards—you are.” This does not necessarily indicate that John knew that Jesus was accused of being illegitimate. For example, later in this verbal slugfest, Jesus calls “the Jews” “children of the devil,” and they call him a Samaritan. Neither of those insults is meant literally, and so we have little reason to think that the insinuation in John 8:41 reflects actual rumors about Jesus’ birth.
The second-century anti-Christian polemicist Celsus relays a story that Mary was impregnated by a Roman soldier named Panthera. The Talmud contains a few cryptic allegations that Jesus was illegitimate, and a medieval Jewish story characterizes him as a child of adultery. For reasons that cannot be considered here, it is best to consider all of these as fabricated responses to the Christian claim that Jesus was born to a virgin.
The notion that Jesus was illegitimate is unsupported by solid historical evidence. While we cannot rule it out completely, we cannot responsibly treat this as anything more than speculative. So, was Jesus fathered by someone other than Joseph? The appropriate answer is that, historically, we have no good reason to think so. Luke’s story of the virgin birth answers that question differently. But stories about miraculous births announced by angels are, of course, not admissible as historical evidence. (Those who believe in the virgin birth do so for religious, not historical, reasons.) Historically, therefore, we should accept the default presumption that Jesus was legitimately fathered by Joseph.