Search for the phrase and you will find it attributed to him on thousands of pages. It is the one thing everybody knows about Machiavelli.
It is not in The Prince. It is not in the Discourses. He did not write it in Italian, and no translator has found it to render into English.
What he did write sits at the end of a long paragraph about reputation, and it is sharper than the slogan it got flattened into.
The actual sentence
Chapter XVIII, on whether a ruler should keep his word. Machiavelli has just finished explaining that a prince must seem merciful, faithful, humane, upright and religious — and that seeming is the operative word:
Every one sees what you appear to be, few really know what you are, and those few dare not oppose themselves to the opinion of the many, who have the majesty of the state to defend them; and in the actions of all men, and especially of princes, which it is not prudent to challenge, one judges by the result.
One judges by the result. Si guarda al fine.
That is the line. And "one judges by the result" is not "the ends justify the means."
Why the difference is not pedantry
"The ends justify the means" is a moral claim. It says: a good enough outcome makes a bad act permissible. It is a licence. It tells you what you may do.
"One judges by the result" is a description of how people behave. It says: whatever you did, you will be assessed on how it turned out. It is not permission, it is a warning about the audience.
Machiavelli is not handing out absolution. He is telling a ruler a fact about the world he operates in — that nobody will examine his reasoning, and almost nobody is in a position to know what he really is, so the verdict will be delivered on results by people with no access to anything else.
You can read that as cynical. You cannot read it as a licence, because it does not say the prince is right. It says he will be judged to be right. Machiavelli is remarkably consistent about this distinction, and the mistranslation erases it completely.
It matters for a second reason. If the ends justified the means, success would make you good. In Machiavelli's version, success only makes you safe — and the same passage notes that the few who really know what you are simply dare not say so. That is not vindication. That is a man describing a protection racket and declining to call it anything nicer.
The other line everybody half-remembers
The same chapter's neighbour, on fear and love, gets quoted almost as loosely:
Upon this a question arises: whether it be better to be loved than feared or feared than loved? It may be answered that one should wish to be both, but, because it is difficult to unite them in one person, it is much safer to be feared than loved, when, of the two, either must be dispensed with.
Two qualifications in a single sentence get dropped every time this is repeated.
First: one should wish to be both. The preferred answer is love and fear. Fear only wins as a fallback.
Second: when, of the two, either must be dispensed with. It is a forced-choice question. He is answering a dilemma, not recommending a policy.
"It is better to be feared than loved" is what survives. The conditional — the whole reason the sentence is interesting — does not.
And his justification is the same unsentimental observation as before:
Because this is to be asserted in general of men, that they are ungrateful, fickle, false, cowardly, covetous, and as long as you succeed they are yours entirely; they will offer you their blood, property, life, and children... when the need is far distant; but when it approaches they turn against you.
Love is unreliable because people are unreliable. It is a claim about human nature, offered as the reason for a tactical preference. Whether it is true is a fair fight. But it is an argument, with a premise, and it is not the shrug it is usually reduced to.
So where did the phrase come from?
Nobody can point to a single culprit, and the honest answer is that it accumulated.
Part of it is translation drift: si guarda al fine can be rendered loosely as "the end is looked to," which slides easily into "the end justifies." Part of it is Machiavelli's reputation arriving before his text — "Machiavellian" was an English insult within decades of his death, and "Old Nick" as a name for the devil may owe something to Niccolò. Part of it is that it is simply a more useful phrase for an opponent than anything he wrote. A slogan you can condemn is worth more than a paragraph you have to read.
The result is that the single most quoted line of early modern political thought is a summary of a reputation rather than a quotation from a book.
What he was actually doing
The Prince is a short job application. Machiavelli had spent fourteen years in the Florentine government, been thrown out when the Medici returned, arrested, tortured, and exiled to a farm. He wrote the book for the family that had destroyed his career, hoping for work.
That context explains its tone better than any theory of evil does. It is written to be useful — it is advice from a technician, assessing what works, deliberately setting aside what ought to work. His own stated novelty, early in the book, is that he intends to describe how men actually live rather than how they should.
Whether that is a moral position, a refusal of one, or a quiet satire of princes has been argued for five hundred years without resolution. It is a genuinely open question.
But it cannot be settled by a sentence he never wrote.
Quotations are from the W. K. Marriott translation of The Prince*, in this site's library. You can read Machiavelli here, or put the charge to him yourself and see how he answers from his own text.*