If a map restricts to an isomorphism on a closed subscheme and its open complement, must it be an isomorphism? 
Suppose $f:X\to Y$ is a morphism of smooth connected schemes (over some base). Say $Z\subseteq Y$ is a closed subscheme with complement $U$ so that $f$ pulls back (restricts) to isomorphisms on $Z$ and $U$. Does it follow that $f$ is an isomorphism?

If we drop the condition that $X$ and $Y$ have to be smooth, the normalization of a cusp is a counterexample. If we remove the hypothesis that $X$ and $Y$ must be connected, taking $X=U\sqcup Z$ gives a counterexample.
 A: Reducing to the affine case, the question is this:
Given a ring homomorphism $R\rightarrow S$, and given an ideal $I\subset R$, suppose that
all of the following are isomorphisms:
$$R/I\rightarrow S/IS$$
$$R_f\rightarrow S_f\quad \hbox{for any $f\in I$}$$
Can we conclude that $R\rightarrow S$ is an isomorphism?
Assuming irreducibility (i.e. assuming $R$ and $S$ are domains) the answer is certainly yes if $I=(f)$ is principal.  Then it's easy to see that $R\rightarrow S$ is injective (because the injection $R\rightarrow R_f\approx S_f$ factors through it).  For surjectivity, let $s\in S$.  Then because $R_f\approx S_f$, we can write $f^ks=r$ for some $r\in R$.  Then $r$ maps to zero in $S/fS$, so $r\in fR$, so (because $f$ is not a zero-divisor) $f^{k-1}s\in R$, contradicting the fact that we could have chosen $k$ minimal.
More generally, if $I=(f_1,\ldots,f_k)$ is finitely generated, then $f_i^N s\in R$ and therefore $f_i^N s\in I\subset R$ for every $i$, which at the very least forces $s$ to be integral over $R$.
I expect you can settle the general case either by generalizing this argument or by constructing $I$ and $S$ in a way that forces it to go wrong.
A: This is essentially the argument in Bhargav's comment. Matt Satriano showed me the separatedness argument.
We first apply the valuative criterion for separatedness to show that $f:X\to Y$ is separated. In fact, this shows that any morphism which is injective on topological spaces must be separated. Suppose $\Delta$ is the spectrum of a valuation ring with closed point $\ast$. Given any map $\Delta\to Y$, there is a unique set theoretic lift to $X$. Therefore, any failure of the valuative criterion will be witnessed on the induced map from an affine open neighborhood of $\ast$ in $X$ to an affine open neighborhood of $\ast$ in $Y$. Since any morphism of affine schemes is separated, the valuative criterion holds, so $f$ is separated.
Since $f$ induces isomorphisms on geometric points, it is quasi-finite. Supposing $Y$ is normal, integral and locally noetherian and $f$ is finite type, Zariski's Main Theorem† tells us that $f$ is an open immersion. Since $f$ is surjective, it is an isomorphism.
† I'm always surprised at how everything seems to be ZMT, so here's a precise reference: EGA III, Corollary 4.4.9. If $Y$ is normal, integral, and locally noetherian, $f:X\to Y$ is separated, birational, finite type, and quasi-finite, then $f$ is an open immersion.
