Let $X_{red}$ denote the reduction of $X$. Then $Z \cap X_{red}$ is a locally principal closed subscheme of $X_{red}$, see Divisors, Lemma \ref{divisors-lemma-pullback-locally-principal}. Hence we may assume that $X$ is reduced. In other words $X$ is integral, see Properties, Lemma \ref{properties-lemma-characterize-integral}. In this case the morphism $X \to S$ factors through $S_{red}$, see Schemes, Lemma \ref{schemes-lemma-map-into-reduction}. Thus we may replace $S$ by $S_{red}$ and assume that $S$ is integral too. \medskip\noindent The assertion that $f$ is dominant signifies that the generic point of $X$ is mapped to $\eta$, see Morphisms, Lemma \ref{morphisms-lemma-dominant-finite-number-irreducible-components}. Moreover, the scheme $X_\eta$ is an integral scheme which is locally of finite type over the field $\kappa(\eta)$. Hence $d = \dim(X_\eta) \geq 0$ is equal to $\dim_\xi(X_\eta)$ for every point $\xi$ of $X_\eta$, see Algebra, Lemmas \ref{algebra-lemma-dimension-spell-it-out} and \ref{algebra-lemma-dimension-at-a-point-finite-type-over-field}. In view of Morphisms, Lemma \ref{morphisms-lemma-openness-bounded-dimension-fibres} and condition (5) we conclude that $\dim_x(X_s) = d$ for every $x \in X_s$. \medskip\noindent In the Noetherian case the assertion can be proved as follows. If the lemma does not holds there exists $x \in Z_s$ which is a generic point of an irreducible component of $Z_s$ but not a generic point of any irreducible component of $X_s$. Then we see that $\dim_x(Z_s) \leq d - 1$, because $\dim_x(X_s) = d$ and in a neighbourhood of $x$ in $X_s$ the closed subscheme $Z_s$ does not contain any of the irreducible components of $X_s$. Hence after replacing $X$ by an open neighbourhood of $x$ we may assume that $\dim_z(Z_{f(z)}) \leq d - 1$ for all $z \in Z$, see Morphisms, Lemma \ref{morphisms-lemma-openness-bounded-dimension-fibres}. Let $\xi' \in Z$ be a generic point of an irreducible component of $Z$ and set $s' = f(\xi)$. As $Z \not = X$ is locally principal we see that $\dim(\mathcal{O}_{X, \xi}) = 1$, see Algebra, Lemma \ref{algebra-lemma-minimal-over-1} (this is where we use $X$ is Noetherian). Let $\xi \in X$ be the generic point of $X$ and let $\xi_1$ be a generic point of any irreducible component of $X_{s'}$ which contains $\xi'$. Then we see that we have the specializations $$ \xi \leadsto \xi_1 \leadsto \xi'. $$ As $\dim(\mathcal{O}_{X, \xi}) = 1$ one of the two specializations has to be an equality. By assumption $s' \not = \eta$, hence the first specialization is not an equality. Hence $\xi' = \xi_1$ is a generic point of an irreducible component of $X_{s'}$. Applying Morphisms, Lemma \ref{morphisms-lemma-openness-bounded-dimension-fibres} one more time this implies $\dim_{\xi'}(Z_{s'}) = \dim_{\xi'}(X_{s'}) \geq \dim(X_\eta) = d$ which gives the desired contradiction. \medskip\noindent In the general case we reduce to the Noetherian case as follows. If the lemma is false then there exists a point $x \in X$ lying over $s$ such that $x$ is a generic point of an irreducible component of $Z_s$, but not a generic point of any of the irreducible components of $X_s$. Let $U \subset S$ be an affine neighbourhood of $s$ and let $V \subset X$ be an affine neighbourhood of $x$ with $f(V) \subset U$. Write $U = \Spec(A)$ and $V = \Spec(B)$ so that $f|_V$ is given by a ring map $A \to B$. Let $\mathfrak q \subset B$, resp.\ $\mathfrak p \subset A$ be the prime corresponding to $x$, resp.\ $s$. After possibly shrinking $V$ we may assume $Z \cap V$ is cut out by some element $g \in B$. Denote $K$ the fraction field of $A$. What we know at this point is the following: \begin{enumerate} \item $A \subset B$ is a finitely generated extension of domains, \item the element $g \otimes 1$ is invertible in $B \otimes_A K$, \item $d = \dim(B \otimes_A K) = \dim(B \otimes_A \kappa(\mathfrak p))$, \item $g \otimes 1$ is not a unit of $B \otimes_A \kappa(\mathfrak p)$, and \item $g \otimes 1$ is not in any of the minimal primes of $B \otimes_A \kappa(\mathfrak p)$. \end{enumerate} We are seeking a contradiction. \medskip\noindent Pick elements $x_1, \ldots, x_n \in B$ which generate $B$ over $A$. For a finitely generated $\mathbf{Z}$-algebra $A_0 \subset A$ let $B_0 \subset B$ be the $A_0$-subalgebra generated by $x_1, \ldots, x_n$, denote $K_0$ the fraction field of $A_0$, and set $\mathfrak p_0 = A_0 \cap \mathfrak p$. We claim that when $A_0$ is large enough then (1) -- (5) also hold for the system $(A_0 \subset B_0, g, \mathfrak p_0)$. \medskip\noindent We prove each of the conditions in turn. Part (1) holds by construction. For part (2) write $(g \otimes 1) h = 1$ for some $h \otimes 1/a \in B \otimes_A K$. Write $g = \sum a_I x^I$, $h = \sum a'_I x^I$ (multi-index notation) for some coefficients $a_I, a'_I \in A$. As soon as $A_0$ contains $a$ and the $a_I, a'_I$ then (2) holds because $B_0 \otimes_{A_0} K_0 \subset B \otimes_A K$ (as localizations of the injective map $B_0 \to B$). To achieve (3) consider the exact sequence $$ 0 \to I \to A[X_1, \ldots, X_n] \to B \to 0 $$ which defines $I$ where the second map sends $X_i$ to $x_i$. Since $\otimes$ is right exact we see that $I \otimes_A K$, respectively $I \otimes_A \kappa(\mathfrak p)$ is the kernel of the surjection $K[X_1, \ldots, X_n] \to B \otimes_A K$, respectively $\kappa(\mathfrak p)[X_1, \ldots, X_n] \to B \otimes_A \kappa(\mathfrak p)$. As a polynomial ring over a field is Noetherian there exist finitely many elements $h_j \in I$, $j = 1, \ldots, m$ which generate $I \otimes_A K$ and $I \otimes_A \kappa(\mathfrak p)$. Write $h_j = \sum a_{j, I}X^I$. As soon as $A_0$ contains all $a_{j, I}$ we get to the situation where $$ B_0 \otimes_{A_0} K_0 \otimes_{K_0} K = B \otimes_A K \quad\text{and}\quad B_0 \otimes_{A_0} \kappa(\mathfrak p_0) \otimes_{\kappa(\mathfrak p_0)} \kappa(\mathfrak p) = B \otimes_A \kappa(\mathfrak p). $$ By either Morphisms, Lemma \ref{morphisms-lemma-dimension-fibre-after-base-change} or Algebra, Lemma \ref{algebra-lemma-dimension-preserved-field-extension} we see that the dimension equalities of (3) are satisfied. Part (4) is immediate. As $B_0 \otimes_{A_0} \kappa(\mathfrak p_0) \subset B \otimes_A \kappa(\mathfrak p)$ each minimal prime of $B_0 \otimes_{A_0} \kappa(\mathfrak p_0)$ lies under a minimal prime of $B \otimes_A \kappa(\mathfrak p)$ by Algebra, Lemma \ref{algebra-lemma-image-dense-generic-points}. This implies that (5) holds. In this way we reduce the problem to the Noetherian case which we have dealt with above.