A republican form of government
In Federalist 10, Madison says there are two ways of removing the causes of factions. One way would be to remove the liberty which allows factions to form. But, he says, that would be a cure worse than the disease. The other way to keep factions from forming would be to give every citizen "the same opinions, the same passions, the same interests." But that's impossible because human beings will always have differences in their opinions, passions and interests.
Madison also expressed concerns about running a society as a complete democracy, because the interests and passions of a majority will tend to squelch and even persecute minority opinions. So, ultimately, he recommends this: "A republic, by which I mean a government in which the scheme of representation takes place, opens a different prospect, and promises the cure for which we are seeking" -- that is, a cure against factionalism.