Jesus's genealogy: 28 generations or 41 since David? These questions keep me wondering:

Firstly, how is it possible that Matthew and Luke came up with completely different genealogies of Jesus's ancestors, if they are both following the masculine line?

And more importantly, if I'm overlooking something and both Matthew and Luke were right, how can this 13-generatons gap be justified?



Added later:

Matthew 1   | Luke 3
------------+-------
David       | David
Solomon     | Nathan
Rehoboam    | Mattatha
Abijah      | Menna
Asa         | Melea
Jehoshaphat | Eliakim
Jehoram     | Jonam
Uzziah      | Joseph
Jotham      | Judah
Ahaz        | Simeon
Hezekiah    | Levi
Manasseh    | Matthat
Amon        | Jorim
Josiah      | Eliezer
            | Joshua
            | Er
            | Elmadam
            | Cosam
            | Addi
            | Melchi
            | Neri
Jehoiachin  |            &lt;-- According to Matthew the exile started here
Shealtiel   | Shealtiel  &lt;-- Same names
Zerubbabel  | Zerubbabel &lt;-- Same names
Abiud       | Rhesa
Eliakim     | Joanan
Azor        | Joda
Zadok       | Josech
Achim       | Semein
Eliud       | Mattathias
Eleazar     | Maath
Matthan     | Naggai
Jacob       | Esli
            | Nahum
            | Amos
            | Mattathias
            | Joseph
            | Jannai
            | Melchi
            | Levi
            | Matthat
            | Heli
Joseph      | Joseph
Jesus       | Jesus
Matthew and Luke had different purposes for their genealogies. Matthew wrote his gospel to present Jesus as King of the Jews. Therefore, his genealogy traces Jesus' descent from Abraham (father of the Hebrew nation) through the royal line of David and Solomon. Luke presented Jesus as the Son of Man and showed his descent from Adam (the first man). 

The difference in purpose explains the answer to both of your questions. The genealogies are different because Matthew gave Joseph's genealogy and Luke gave Mary's. Physically, Jesus was Mary's son, not Joseph's, so it makes sense that Luke, who stressed Jesus' humanity, would show Jesus' physical line in his genealogy. Matthew, presenting Jesus as a Jew and of the kingly line, shows Jesus' adopted father Joseph's genealogy. Wikipedia lists some possible explanations for why Luke says Joseph was the son of Heli.

The gaps are because Matthew only selectively chose noteworthy names for his genealogy; that's how we get exactly fourteen generations between Abraham and David, David and the Captivity, and the Captivity and Christ. Luke lists close to twice as many names in his genealogy because he wanted to show Jesus' humanity by specifically listing all or most of his ancestors.