How could David enter the congregation of the Lord when he was descended from Ruth the Moabitess? I want to ask a question about Ruth the Moabitess and King David.


  Deuteronomy 23:3
  An Ammonite or Moabite shall not enter into the congregation of the LORD; even to their tenth generation shall they not enter into the congregation of the LORD for ever:


And Ruth was a Moabitess, AND, the great grandmother of King David.


  Ruth 1:22
  So Naomi returned, and Ruth the Moabitess, her daughter in law, with her, which returned out of the country of Moab: and they came to Bethlehem in the beginning of barley harvest.


MY QUESTION IS

Logically, how can David be lawfully accepted 'into the congregation of the Lord' (let alone, be selected by the LORD to be King of Israel,) when he was clearly only 3 generations away from Moab heritage?

I am searching for any scriptural explanation, which would justify David being accepted 'into the congregation of the Lord', taking into account the clear "even to their tenth generation" prohibition of Deuteronomy 23:3.

And, doesn't Jewish heritage follow the mother?
Naomi fled from the famine in Judah to live in Moab with her husband and two sons. Her two sons eventually married Moabite wives including Ruth. Naomi’s husband and sons eventually died and she decided to return to her homeland. Ruth clung onto her with a pledge that ‘your people will be my people and your God will be my God.’ (Ruth 1:16). Though she was a Moabite, Ruth was ‘acquired’/purchased by Boaz, the guardian/kinsman redeemer of Naomi’s family (Ruth 4:9-10).  Scripture says, “the Lord enabled her to conceive, and she gave birth to a son” (see vs 13, NIV) - Obed, who was David’s grandfather. In a short genealogy of David (see Ruth 4:21-22), Boaz is listed as the father of Obed, the father of Jesse, the father of David. This was in line with Jewish culture where children are the offspring of their fathers and not their mother. Indeed throughout history, Jewish men did marry or produce children from captive or slave non-Jewish women and the off-spring became Jewish because of their fathers. So technically, Obed, the grandfather of David, was the son of Boaz and not Ruth.