[The following post depends greatly upon the discussion by John P. Meier in A Marginal Jew vol. 1 pp. 89-111 and esp. 222-229, and Lynn H. Cohick’s Women in the World of the Earliest Christians, pp. 152-156.]
As early as the second century we have record of allegations that Jesus was born illegitimately. But is there any evidence that these charges go back even further? We start with noting that in Justin Martyr’s Dialogue with Trypho (dating is debated but it was probably written after A.D. 150) there is no mention of it. Justin was an apologist and in this book he is arguing with a Jew over matters related to Jesus. One of those issues is the virgin birth. It is significant that in their lengthy discussion nothing is ever mentioned about Jesus being illegitimate.
In the New Testament itself two passages are most often appealed to in order to show that the charge was fairly early: Mark 6:3 and John 8:41.
Mark 6:3 reads, “Is not this the carpenter, the son of Mary and brother of James and Joses and Judas and Simon? And are not his sisters here with us?" And they took offense at him.” (ESV)
John 8:41 reads, “You are doing the works your father did." They said to him, "We were not born of sexual immorality. We have one Father—even God." (ESV)
The argument goes something like this: In Mark the reference to Jesus as “son of Mary” is unusual since people were referred to by who their father was not their mother. The reference is a subtle hint at Jesus’ illegitimate birth. In John the Jewish leaders mention that they are not “born of sexual immorality.” Surely this must be seen as a slur against Jesus’ own birth.
While even conservative commentaries often come to similar conclusions I don’t think it is a necessary one. What about Jesus being called “son of Mary”? It’s true that this is an unusual expression. Most people of the time were referred to by their father even after the father had died. But not always. Meier points to the Old Testament case of Zeruiah, the mother of Joab, Abishai, and Asahel, three leaders of King David’s troops. He notes, “These three notables—individually or together—are always identified in the Bible as the ‘son[s] of Zeruiah’ their mother, never as the sons of their father (see, e.g., 1 Sam. 26:6; 2 Sam. 2:23; and so without exception throughout 1-2 Samuel, 1 Kings, and 1 Chronicles, for a total of 24 occurrences). The usage continues in Josephus and the rabbinic literature.” (226) He concludes “The phrase indicates illegitimacy no more than it indicates virginal conception—another interpretation to which this battered text at times has been subjected.” Furthermore, Lynn Cohick observes that Jesus’ siblings are also mentioned. While these could be half- (or step) siblings she says “it is possible that all the children mentioned are Mary’s; since the other children’s legitimacy is not questioned, and Jesus is grouped with them, we could assume that the townsfolk are not commenting on Jesus’s illegitimacy.” (154) Finally, she notes that a textual variant does exist which reads “son of the carpenter and of Mary.” If this is the original reading then this could indicate a scribal change that removed the reference to the carpenter’s son thereby hinting at the virgin birth (especially since Mark does not include a nativity narrative). The expression therefore, in and of itself, cannot be used to indicate an illegitimate birth.
What about John 8:41? Meier shows from the context that it is Jesus that is on the attack here. He has accused the leaders that they have a father who is not Abraham but rather they were doing the works of their real father—the devil. According to Meier “Jesus, in effect, has accused them of disobedience or infidelity toward God. They reply: We are not guilty of spiritual infidelity to or apostasy from God, sins described in the OT in terms of fornication.” (228) Furthermore, “when the verbal battle becomes even fiercer in v 48, when for the first time the Jews stop defending themselves and start attacking Jesus with slurs, their first accusation is that he is a Samaritan. This is hardly intended in a physical, biological sense. Rather, by questioning the Jerusalemite Jews’ status as the true children of Abraham, Jesus, in their minds, is aligning himself with the ‘heterodox and schismatic’ Samaritans, who question the Jews’ status as the only children of Abraham and Jerusalem’s status as the one true place of temple worship.” (228) Meier concludes that “the theme of illegitimacy in John 8—as in Mark 6:3—must be judged a classic case of retrojecting later theological debates into an earlier text that shows no signs of such disputes.” (229)
Cohick adds another consideration—the accusation of Jesus befriending tax collectors and sinners. She says “if he was illegitimate, no one would comment on the fact that he was mixing with what would be seen as his own crowd. That he is with those ‘beneath’ him on the social ladder is what generates the comments and the shock. If he was the illegitimate outcast that some describe, no one in any leadership capacity would give him two minutes of their time. . . instead, it seems that Jesus spoke in synagogues, dined with Pharisees, and did the sorts of things that no outcast or illegitimate son would have the opportunity to do.” (155)
If this were a court case I think the testimony of both Cohick and Meier present enough evidence to give plenty of "reasonable doubt" on the charge of illegitimacy against Jesus. That it was true in later centuries there is no doubt but there is little, if any, evidence that it goes back to New Testament times.