In the United States, Ph.D. qualifying exams or quals (also called comprehensive exams or comps, preliminary exams or prelims, and other terms) date back to the late 1930s and proliferated in the postwar period, according to Leonard Cassuto (Chronicle; also noted in the "Comprehensive Exams" chapter of his book The Graduate School Mess):
Comps seem as old as graduate school itself, so that tampering with them might appear the equivalent of rewriting the sacred scrolls. But comprehensive exams in the United States date back only to the late 1930s. They proliferated when graduate populations grew too large after World War II to manage by dissertation alone. Between the GI Bill and Sputnik-related research spending, the number of Ph.D.'s tripled in the 1960s. Against that backdrop, the dissertation defense became more of a formality, creating a need for so-called barrier exams beforehand.
Comprehensive exams had already existed in some departments for undergraduate students, but there was a lack of standardization for curricula at different colleges. For example, a graduate of another university who wanted to earn an MA from Princeton would have to take their senior comprehensive exam covering the undergraduate curriculum at Princeton. Economics professor Richard A. Lester, in "A Critique of Our Colleges" (The American Scholar, 3(4), 1934), uses this example to attack the insularity of graduate education at the time, which favored students from its own institution.
Still, occasional evidence for earlier PhD qualifying exams can be found. In a review for Jacob Viner: Lectures in Economics 301 in Journal of Economic Literature 52(2) (2014), a footnote cites PhD qualifying exams found in the Albert G. Hart papers at Columbia. "Hart had been a graduate student at Chicago from 1931 to 1936," indicating that PhD exams were in place in the economics department at the University of Chicago. That does not indicate that PhD exams were widespread, but only that deep dives into institutional archives might uncover earlier examples that Cassuto may not have been aware of.