Niccolo Machiavelli shocked his contemporaries, and can still shock us, with his easy acceptance of the role of violence and cruelty in worldly success. At one point in his best-known work, The Prince, he argues casually that Fortune should be raped: "Fortune is female and if you want to stay on top of her you have to slap and thrust … she's more likely to yield that way."

It's a horrible picture that manages to upset us in a way that the book's central theme upset its first readers: what if the Christian idea that politics must be subject to justice was wrong? What if might is actually right?

This was not a theoretical issue. Machiavelli lived his entire life in an age in which deceit and brutality usually won through. His genius lay in his ability to see and his honesty in admitting this.

He was born in Florence in 1469, the year that Lorenzo de' Medici (not the Lorenzo to whom The Prince is dedicated) assumed power. "Assumed" is technically misleading as Florence had been a republic for more than a century. However, the system of regular, short-term elections through which power was diffused had proved perilously unstable. By the mid 15th century, real power lay in the hands of a small number of rich families, the Medicis supreme among them. This disjunction between political theory and reality would leave a deep mark on Machiavelli.

The confusion within Florence was matched by disorder without, as the five main Italian powers – Florence, Venice, Milan, the Papal states and Naples – lived in a state of constant intrigue, negotiation and conflict, made more complex still by the invasion of the French king, Charles VIII, at Milanese invitation, in 1494.

This invasion saw the humiliation of Florence and the temporary overthrow of the Medicis when Lorenzo's son, Piero, surrendered to the French and was replaced by Girolamo Savonarola, a puritanical, book-burning Dominican friar, who sought to reform the church and Florentine society. His execution at the stake, four years later, changed Florence's political course once again, opening the door to Machiavelli's diplomatic career and further confirming that "a ruler must never imagine that any decision he takes is safe", as he put it at the end of The Prince.

If, then, there was no such thing as complete political security, how could a ruler hope to survive, let alone triumph? Machiavelli's answer is sketched out in The Prince, which he wrote in 1513.

He argued, along with many contemporaries, that while a leader could never fully conquer the goddess Fortune, he could at least make an effort to woo and master her. Where he differed from his contemporaries was how.

Weak leaders, in his experience, were disastrous. Piero de Medici had been incompetent and submissive. Piero Soderini, the head of state for whom Machiavelli would work as a diplomat, was hopelessly indecisive. Even Savonarola, although forceful himself, had no recourse to force and thus "was overthrown along with all his reforms when people stopped believing in him."

By contrast, strong leaders achieved (a measure of) security and fame. Pope Julius II achieved all three (military) aims he set himself. Pope Alexander VI "showed what could be done with finance and force." Supremely, there was Cesare Borgia, Alexander's son, of whom Machiavelli says: "I wouldn't know what better advice to give a ruler new to power than to follow his example."

Machiavelli charts Cesare's machinations at length, detailing how he disguised his intentions, weakened opposing factions, broke old loyalties, enriched allies and eliminated rivals. At one point he tells how Cesare appointed a "cruel, no-nonsense man" to pacify a newly acquired territory. The appointment was successful but Cesare, recognising how his man's severity had provoked local enmity, "found a pretext … had [him] beheaded and his corpse put on display one morning in the piazza … with a wooden block and a bloody knife beside … The ferocity of the spectacle," Machiavelli records, "left people both shocked and gratified."

Cesare was not simply a mindless butcher, however. Elsewhere, Machiavelli tells how, having taken control of Romagna, Cesare found existing rulers "had been stripping the people of their wealth rather than governing them". As a result, he decided that "good government was required to pacify the area".

What impressed Machiavelli was not so much Cesare's viciousness as his readiness to do what was necessary when it was necessary. Only this kind of cold-blooded determination would allow a prince to stay atop Fortune and survive.

Instinctively, we want morality to show us a world where these choices don't have to be made. But the challenge of Machiavelli, for Christians and atheists alike, is that he confronts us with a terrible argument: we cannot do good without power but we cannot gain power, nor keep it, without doing evil.

• Follow Comment is free on Twitter @commentisfree