These verses are 1 Samuel 23:6 and 2 Samuel 8:17:
Unless I've missed something, the straightforward solution is that Abiathar named his son Ahimelech, after his own father, who was murdered by Saul at 1 Samuel 22:18. I don't see any further problem.
Alternatively, the NIV Study Bible explains this as a scribal error: that one of the scribes copying the passage just reversed the two names by accident.
Back to errancy.org main index