From A Comprehensive Dictionary of Mathematics by Roger Thompson: "quod erat demonstrandum" (Latin) -- This stems from medieval translators' habitual tendency of translating the Greek for "this was to be demonstrated" to the Latin phrase above. This appeared originally at the end of many of Euclid's propositions, signifying that he had proved what he set out to prove.
Nowadays, many people do not end their proofs with quod erat demonstrandum or Q.E.D. but with $\Box$ or $\blacksquare$; there are other variants too, of course, but the overall meaning is to ultimately signify the end of a proof.
From Encyclopedia of Mathematics by James Tanton [supplemental]: The initials QEF, for quod erat faciendum (which was to be done), are sometimes added after the completion of a geometrical construction, and QEI, for quod erat inveniendum (which was to be found), after the completion of a calculation.
From Origins of Mathematical Words - A Comprehensive Dictionary of Latin, Greek, and Arabic Roots by Anthony Lo Bello: