This is kind of silly but I haven't really seen it concretely written down anywhere.
Given a system of first-order logic you don't need to have a concrete system of terms at all but can only use variables. You can emulate terms using total functional relations. Substitution then becomes the much simpler to implement renaming of variables.
As an example take Peano arithmetic.
You have axioms the terms are total functional
$$ \top \vdash \exists! x. \text{O}(x)$$
$$ \top \vdash \forall x. \exists! y. \text{S}(x, y) $$
Distinctness becomes something like
$$ \top \vdash \forall x y. \neg( \text{O}(y) \wedge \text{S}(x, y) )$$
This becomes quite quite painful to work with in practice and is probably mostly useful in metatheory.
An uglier multisorted mechanical translation of the untyped lambda calculus might be something like the following.
All terms are converted to relations
$$ R \mathrel{::=} \text{var}(x, e) \mid \text{lam}(x, e_1, e_2)
\mid \text{app}(e_1, e_2, e_3)
\mid \text{subst}(x, e_1, e_2, e_3)$$
Do not confuse variables within the theory of lambda calculus with variables within the framework of first order logic.
All terms are axiomized as total functional.
$$\vdash \forall x. \exists! e. \text{var}(x, e) $$
$$\vdash \forall e_1 e_2. \exists! e_3. \text{app}(e_1, e_2, e_3) $$
$$\vdash \forall x e_1. \exists! e_2. \text{lam}(x, e_1, e_2) $$
$$\vdash \forall x e_1 e_2. \exists! e_3. \text{subst}(x, e_1, e_2, e_3) $$
Beta reduction becomes something like
$$ \vdash \forall x e_1 e_3 e_4.(\exists e_2. \text{lam}(x, e_1, e_2) \wedge \text{app}(e_2, e_3, e_4)) \iff \text{subst}(x, e_1, e_3, e_4) $$
Of course you wouldn't usually do something like this in practice. Things become completely unreadable sigils. Axiomizing capture avoiding substitution like this would also be hellish. But it's in an interesting thing to have in your toolkit and could be merely difficult instead of hellish if you compiled down from a higher level.
In practice among other tweaks you would probably want to take advantage of the relational style and make substitution a partial function instead of total functional. I just wanted to explain the mechanical nature of the translation.