Definition 1. The filters on a class $I$ are the nonempty subclasses of $\mathcal P(I) \setminus \{\varnothing\}$ closed under supersets in $\mathcal P(I)$ and under binary intersection.
Lemma 1. The union of a nonempty $\subset$-chain of filters on a class $I$ is a filter on $I$.
Proof. Suppose $I$ is a class and $C$ is a nonempty $\subset$-chain of filters on $I$, and let $F$ be the union of $C$.
Every member of $C$ is a filter and hence is nonempty, and $C$ itself is nonempty, so $C$ has a nonempty member, and hence its union is nonempty.
Suppose $\varnothing \in F$. Then there is a $G \in C$ such that $\varnothing \in G$. But this $G$ is a filter on $I$, and no filter on $I$ contains $\varnothing$. So $\varnothing \not \in F$.
Suppose $A \in F$, $B \in \mathcal P(I)$ and $A \subseteq B$. Then there is a $G \in C$ such that $A \in G$. This $G$ is a filter on $I$, and hence is closed under supersets in $\mathcal P(I)$, so we have $B \in G$ and hence $B \in F$.
Suppose $A$ and $B$ are in $F$. Then there are sets $G$ and $H$ in $C$ such that $A \in G$ and $B \in H$. Because $C$ is a $\subset$-chain, we can assume without loss of generality that $G \subseteq H$ and hence both $A$ and $B$ are in $H$. This $H$ is a filter on $I$, and hence is closed under binary intersection, so it follows that $A \cap B \in H$ and hence $A \cap B \in F$.
Definition 2. The ultrafilters on a class $I$ are the $\subset$-maximal filters on $I$.
Theorem (Ultrafilter Lemma). For every set $I$ and every filter $F$ on $I$, there is an ultrafilter on $I$ including $F$.
Proof. Define a sequence $(U_n : n \in \mathsf{On})$ by transfinite recursion like so:
If there is a filter $G$ on $I$ such that $U_n \subset G$, then let $U_{n + 1} = G$ (details 1).
Otherwise, let $U_{n + 1} = U_n$.
For every limit ordinal $n$, let \begin{equation*} U_n = \bigcup_{m < n} U_m. \end{equation*}
We shall prove by transfinite induction that for every ordinal $n$, the class $U_n$ is a filter on $I$ and includes every class of the form $U_m$, where $m < n$.
$U_0 = F$, and $F$ is a filter on $I$.
Suppose $n$ is an ordinal and $U_n$ is a filter on $I$ and includes every class of the form $U_m$, where $m < n$. Then:
If there is a filter $G$ on $I$ such that $U_n \subset G$, then $U_{n + 1} = G$ is a filter on $I$ and if $m \in n + 1$, then either $m \in n$, in which case $U_m \subseteq U_n \subset G$, or $m = n$, in which case $U_m = U_n \subset G$.
Otherwise, we have $U_{n + 1} = U_n$, and $U_n$ is a filter on $I$ and includes every class of the form $U_m$, where $m \in n$.
Suppose $n$ is a limit ordinal and for every $m < n$, the class $U_m$ is a filter on $I$ and includes every class of the form $U_k$, where $k < m$. Then for every pair $i, j$ of distinct ordinals less than $n$ such that $i < j$, we have $U_i \subseteq U_j$; so the set $\{U_m : m < n\}$ is a $\subset$-chain of filters on $I$, and hence its union $U_n$ is a filter on $I$ by Lemma 1.
Now, suppose that for every ordinal $n$, there is a filter $G$ on $I$ such that $U_n \subset G$. Then $U_{n + 1} = G$ is a proper superset of $U_n$ and moreover, for every $m < n$, we have $U_m \subseteq U_n \subset U_{n + 1}$. So for every ordinal $n$ and every ordinal $m < n$, we have $m + 1 \le n$, and hence $U_m \subset U_{m + 1} \subseteq U_n$. So $(U_n : n \in \mathsf{On})$ is injective. Because $\mathcal P(I)$ is a codomain of this sequence, it follows that $\mathcal P(I)$ is a proper class (details 1 below) and hence $I$ is a proper class. But $I$ is a set. So there is an ordinal $n$ such that $U_n$ is not properly included by any other filter on $I$, i.e. $U_n$ is an ultrafilter. And $F = U_0 \subseteq U_n$. $\blacksquare$
Details 1. This part of the proof makes use of the axiom of choice. This may be easy to miss because of the linguistic shortcut I have allowed myself to use here: I know that there is some $G$ with the property I want and so then I feel free to assign to $U_{n + 1}$ a definite such $G$. This is not a manoeuvre that can be translated straightforwardly into the language of first-order logic. If I wanted to write in a style that hews more closely to how the proof would be translated into first-order logic, I would add a paragraph to the start of the proof reading like so:
“For every filter $G$ on $I$, let $V_G = \{H : H \text{ is a filter on $I$} \wedge G \subseteq H\}$. Let $X$ be the class of the sets of the form $V_G$, where $G$ is a filter on $I$. By the axiom of choice, there is a mapping $f$ on $X$ such that for every filter $G$ on $I$, we have $f(V_G) \in V_G$, i.e. $f(V_G)$ is a filter on $I$ and $G \subseteq f(V_G)$.”
Then, later on in the proof, rather than saying “let $U_{n + 1} = G$”, I would say “let $U_{n + 1} = f(V_G)$”.
Details 2. $\mathsf{On}$ is a proper class, due to the Burali-Forti paradox (I will not cover this here). The principle of limitation of size says that all proper classes have the same “cardinality”, which is strictly greater than any cardinality a set can have. So if $\mathsf{On}$ is injectable into a class $A$, then by definition this means that the cardinality of $A$ is at least the cardinality of $\mathsf{On}$, and hence $A$ is also a proper class.
This can also be derived as a consequence of replacement: take the injection and invert it, and you get a surjection from a subclass of $A$ onto $\On$; if $A$ is a set, then its subclass is also a set, and hence by the axiom of replacement $\mathsf{On}$ must also be a set.