In the heyday of their republic, the Venetians selected their lifetime leader, the Doge, by a complex system involving lot-drawing. The system had developed through the Middle Ages, becoming ever more complex to avoid manipulation, before being codified in 1268. The procedure consisted of a series of ten ballots that alternated between sortition and election. All participants had to belong to the Great Council, which included several hundred members of the most prominent families. The process might be called fetura, for the Latin for breeding, the same method used in genetic or evolutionary algorithms. The steps were as follows (Dahl 1994, 14-16):

1. The ballottino, a boy chosen at random, draws thirty names by plucking balls out of an urn, thus setting the process in motion with a blind draw.

2. Those thirty are reduced to nine by a blind draw.

3. Those nine put forward forty names, each of which needs at least seven of the nine possible votes.

4. Those forty are reduced to twelve by a blind draw.

5. Those twelve put forward twenty-five names.

6. Those twenty-five are reduced to nine by a blind draw.

7. Those nine choose forty-five new names, each of which needs at least seven of the nine possible votes.

8. Those forty-five are reduced to eleven by a blind draw.

9. Those eleven choose forty-one, who must not have been included in any of the reduced groups that named candidates in earlier steps.

10. Those forty-one then choose the Doge.

The Venetian system seems devised to make it impossible for any individual, family, or coterie to plant candidates or exercise undue influence. However convoluted the procedure, it supported a republican government that lasted 529 years, until 1797, when Venice was conquered by Napoleon.

From Wikipedia:

Venetian system

New regulations for the elections of the doge introduced in 1268 remained in force until the end of the republic in 1797. Their object was to minimize as far as possible the influence of individual great families, and this was effected by a complex elective machinery. Thirty members of the Great Council, chosen by lot, were reduced by lot to nine; the nine chose forty and the forty were reduced by lot to twelve, who chose twenty-five. The twenty-five were reduced by lot to nine and the nine elected forty-five. Then the forty-five were once more reduced by lot to eleven, and the eleven finally chose the forty-one who actually elected the doge. None could be elected but by at least twenty-five votes out of forty-one, nine votes out of eleven or twelve, or seven votes out of nine electors.