Answer
Jesus’ genealogy is given in two places in Scripture: Matthew 1 and Luke 3:23-38. Matthew traces the genealogy from Jesus to Abraham. Luke traces the genealogy from Jesus to Adam. However, there is good reason to believe that Matthew and Luke are in fact tracing entirely different genealogies. For example, Matthew gives Joseph’s father as Jacob (Matthew 1:16), while Luke gives Joseph’s father as Heli (Luke 3:23). Matthew traces the line through David’s son Solomon (Matthew 1:6), while Luke traces the line through David’s son Nathan (Luke 3:31). In fact, between David and Jesus, the only names the genealogies have in common are Shealtiel and Zerubbabel (Matthew 1:12; Luke 3:27).
Some point to these differences as evidence of errors in the Bible. However, the Jews were meticulous record keepers, especially in regard to genealogies. It is inconceivable that Matthew and Luke could build two entirely contradictory genealogies of the same lineage. Again, from David through Jesus, the genealogies are completely different. Even the reference to Shealtiel and Zerubbabel likely refer to different individuals of the same names. Matthew gives Shealtiel’s father as Jeconiah while Luke gives Shealtiel’s father as Neri. It would be normal for a man named Shealtiel to name his son Zerubbabel in light of the famous individuals of those names (see the books of Ezra and Nehemiah).
One explanation, held by the church historian Eusebius, is that Matthew is tracing the primary, or biological, lineage while Luke is taking into account an occurrence of “levirate marriage.” If a man died without having any sons, it was tradition for the man’s brother to marry the widow and have a son who would carry on the deceased man’s name. According to Eusebius’s theory, Melchi (Luke 3:24) and Matthan (Matthew 1:15) were married at different times to the same woman (tradition names her Estha). This would make Heli (Luke 3:23) and Jacob (Matthew 1:15) half-brothers. Heli then died without a son, and so his (half-)brother Jacob married Heli’s widow, who gave birth to Joseph. This would make Joseph the “son of Heli” legally and the “son of Jacob” biologically. Thus, Matthew and Luke are both recording the same genealogy (Joseph’s), but Luke follows the legal lineage while Matthew follows the biological.
Most conservative Bible scholars today take a different view, namely, that Luke is recording Mary’s genealogy and Matthew is recording Joseph’s. Matthew is following the line of Joseph (Jesus’ legal father), through David’s son Solomon, while Luke is following the line of Mary (Jesus’ blood relative), through David’s son Nathan. Since there was no specific Koine Greek word for “son-in-law,” Joseph was called the “son of Heli” by marriage to Mary, Heli’s daughter. Through either Mary’s or Joseph’s line, Jesus is a descendant of David and therefore eligible to be the Messiah. Tracing a genealogy through the mother’s side is unusual, but so was the virgin birth. Luke’s explanation is that Jesus was the son of Joseph, “so it was thought” (Luke 3:23).