Let me give you a historical background first. Until the end of 19th century logic was almost exclusively associated with Aristotelian logic, the syllogistic. This logic did not have quantifiers, or even propositional variables, in other words it was too weak to support even arithmetic, let alone the rest of mathematics (Chrysippus, an ancient Stoic, and Leibniz conceived of modern propositional logic before Frege, but their ideas were disregarded and largely forgotten). It is due to this weakness that philosophers like Locke, Hume, and Kant, considered analytic knowledge, achievable through "pure logic", as entirely trivial and incapable of producing anything of substance, see Was Locke right that analytic knowledge is vacuous? Mathematics, on the other hand, clearly displayed non-trivial truths, as Euclid's work amply demonstrated, and so could not possibly reduce to logic. Kant even invented a new notion of "synthetic a priori" that rely on additional faculty of productive imagination to take mathematics beyond mere logic. Friedman in Kant's Theory of Geometry explains in detail how the lack of quantification in the syllogistic forced early calculus and analysis to rely on intuitive ideas about motion, preventing more formal constructions.
So before introduction of quantificational logic by Frege and Peirce at the end of 19th century, see Bonevac's History of Quantification, by mathematics and logic did not need to be specifically distinguished, they were worlds apart. Peirce, who took early philosophical notice of the algebraization and formalization of mathematics in 19th century, believed that it does not require formal logical foundations, and that quite the opposite, logic (whose scope he understood expansively in the Kantian-Hegelian sense) depends on mathematics philosophically. It was Frege who thought the other way, and developed the technical means for reducing arithmetic (and the rest of mathematics) to logic in his ground-breaking Begriffsschrift, eine der Arithmetischen Nachgebildete Formelsprache des Reinen Denkens (Concept-Script: A Formal Language for Pure Thought Modeled on that of Arithmetic, 1879), and in Grundgesetze der Arithmetik (1893) proposedoutlined a programme of reducing arithmetic (and the rest of mathematics) to logic, known as logicism. This programme indeed envisioned logic, the new mathematical logic, in a single unit with mathematics and metamathematics, both as their tool and foundation.
However, logicism quickly ran into troubles, first with the Russell's paradox, which showed onesome of Frege's "basic laws of thought" was defectiveto be problematic (the comprehension schema claimingBasic Law V, the law of extensions, combined with the substitution principle implied that every predicate defines a class, which produced Russell's paradoxical class). And then when Russell attempted to remedy this in his Principia it turned out that even Frege's logic could not support all of mathematics without extra assumptions of distinctly non-logical flavor, like the notorious axiom of reducibility. The final blow to classical logicism, in its last incarnation developed by Carnap, was delivered by Gödel's incompleteness theorem, which ended the idea that an all-encompassing logical system can serve as a foundation for both mathematics and itself, see Friedman's Logical Truth and Analyticity in Carnap's "Logical Syntax of Language" for detailed discussion of subtleties involved. It ended even a more generous proposal for basing meta-mathematics on "geometry of symbols" in addition to logic, Hilbert's formalism, see Was there a Kantian influence on Hilbert's formalist programme? More recently however, some neologicist proposals were advanced by Heck and Hale-Wright.