We want to show that, if $V$ is an open subset of $Y$, then $f^{-1}(V)$ is open in $X$. In other words, we need to show that, for any $x \in f^{-1}(V)$, there is an open neighbourhood $U_x$ of $x$ with $f(U_x)\subseteq V$.
If you want to use the tube lemma, the key is to notice that if $y\neq f(x)$, then there is an open set $U_y\times V_y \subseteq X\times Y$ where $U_y$ is an open subset of $X$ containing $x$ and $V_y$ is an open subset of $Y$ containing $y$, which is disjoint from $\Gamma_f = \{(x,f(x)): x\in X\}\subseteq X\times Y$. Thus if $z\in U_y$, then $f(z)\notin V_y$. Now the open sets $\{V_y:y \in Y\backslash \{f(x)\}\}$ has $\bigcup_{y \in Y\backslash \{f(x)\}} V_y = Y\backslash \{f(x)\}$, so the $V_y$ are almost an open cover of $Y$.
The rest of the proof works by adding a suitable open set to the $\{V_y\}$ so that you obtain an open cover of $Y$, and then examining what compactness gets you.
You can also reorganise the above argument in the following way (based on the sort of approach Carsten S. takes abvoe) which perhaps makes the "tube" come to the forefront more. It at least separates clearly the roles played by compactness of $Y$ and the property that the graph is closed in proving the continuity of $f$.
Claim 1: If $Y$ is compact, then the map $p_1 \colon X\times Y \to X$ is closed (that is, if $F\subseteq X\times Y$ is closed, then its image $p_1(F)$ is closed.
Proof of claim: We show $p_1(F)^c\subseteq X$ is open in $X$. Indeed if $x \in p_1(F)^c$, then $(\{x\}\times Y) \cap F = \emptyset$, or equivalently $(\{x\}\times Y \subseteq F^c$, an open subset of $X\times Y$. Thus each $(x,y)\in \{x\}\times Y$ lies in an open of the form $U_y\times V_y \ni (x,y)$ with $U_y$ open in $X$ and $V_y$ open in $Y$. Then the $\{V_y: y \in Y\}$ form an open cover of $Y$, so that by compactness, there is a finite subset $B\subseteq Y$ with $Y = \bigcup_{b in B} V_b$. Since $x \in U_y$ for all $y \in Y$, $U_x := \bigcap_{b \in B} U_b$ is an open neighbourhood of $x$ in $X$ and $U_x\times Y\subseteq F^c$ (i.e. since $\{x\}\times Y$ is compact, if it is disjoint from $F$ then it lies in a tube $U_x\times Y$ which is also disjoint from $F$. But then clearly $U_x \subseteq p_1(F)^c$ and so $p_1(F)^c$ is open as required.
Claim 2: If $\Gamma_f= \{(x,f(x)): x \in X\}$ is closed in $X\times Y$ and $Y$ is compact, then $f$ is continuous.
(Sketch) proof:
I won't give a complete proof of this so as not to give the game away on everything, notice there is a map $F\colon X \to X\times Y$ given by $F(x) = (x,f(x))$, and it is easy to see that $F$ is continuous if and only if $F$ is. Now the restriction $p_f$ of $p_1$ to $\Gamma_f = F(X)$ is the inverse of $F$, and $p_f$ is certainly continuous, so its inverse $F$ is continuous provided $p_f$ is an open map, that is, a map for which the image of an open set is open. Since $F$ and $p_f$ are bijections, it is easy to see that $p_f$ is an open map if and only if it is a closed map. But if $\Gamma_f$ is closed, then any closed set in $\Gamma_f$ is a closed set in $X\times Y$, and claim $1$ showed that such sets are sent to closed sets in $X$, hence $p_f$ is a closed (and open) map as required.