A nail is driven out by another nail. Habit is overcome by habit.
Usually credited to Erasmus alone, but it is two sayings joined. “To drive out one nail with another” is in Erasmus’s Adages (first published 1500). “Custom is overcome by custom” is from Thomas à Kempis’s The Imitation of Christ, about eighty years earlier.