Machiavelli was born in a tumultuous era—popes waged acquisitive wars against Italian city-states, and people and cities often fell from power. Along with the pope and the major cities like Venice and Florence, foreign powers such as France, Spain, the Holy Roman Empire, and even Switzerland battled for regional influence and control. Political-military alliances continually changed, featuring condottieri (mercenary leaders), who changed sides without warning, and the rise and fall of many short-lived governments.
Machiavelli was taught grammar, rhetoric, and Latin. It is thought that he did not learn Greek, even though Florence was at the time one of the centers of Greek scholarship in Europe. In 1494, Florence restored the republic—expelling the Medici family, who had ruled Florence for some sixty years. Shortly after the execution of Savonarola, Machiavelli was appointed to an office of the second chancery, a medieval writing office which put Machiavelli in charge of the production of official Florentine government documents. Shortly thereafter, he was also made the secretary of the Dieci di Libertà e Pace. In the first decade of the sixteenth century, he carried out several diplomatic missions: most notably to the Papacy in Rome, in the Italian states. Moreover, from 1502 to 1503 he witnessed the brutal reality of the state-building methods of Cesare Borgia (1475–1507) and his father, Pope Alexander VI, who were then engaged in the process of trying to bring a large part of central Italy under their possession. The pretext of defending Church interests was used as a partial justification by the Borgias. Other excursions to the court of Louis XII and the Spanish court influenced his writings and appear in The Prince and several other of his non-fiction works.
Between 1503 and 1506, Machiavelli was responsible for the Florentine militia. He distrusted mercenaries (a distrust he explained in his official reports and then later in his theoretical works, due to their unpatriotic and uninvested nature in war, making their allegiance fickle and often to waver when most needed), and instead staffed his army with citizens, a policy which proved to be successful many times. Under his command Florentine citizen-soldiers defeated Pisa in 1509; however, Machiavelli's success did not last. In August 1512, the Medici, helped by Pope Julius II, used Spanish troops to defeat the Florentines at Prato, although many historians have argued that this was due to Piero Soderini's