[proofplan]
We prove both directions using the standard affine local-global principles for finite modules. A finitely generated projective module is a direct summand of a finite free module, and after localization at a prime it becomes a finitely generated projective module over a local ring, hence free. Conversely, if $P$ is Zariski-locally finite free, then a finite principal [open cover](/page/Open%20Cover) of $\operatorname{Spec}(R)$ reduces projectivity to the standard finite local-global projectivity criterion.
[/proofplan]
[step:Record the local algebra facts used in the proof]
We use the following standard facts.
First, [localization is exact](/theorems/2845) and preserves finite direct sums and direct summands. Thus if an $R$-module $M$ is a direct summand of $R^n$, then for every multiplicative set $S\subset R$, the localized module $S^{-1}M$ is a direct summand of $(S^{-1}R)^n$.
Second, if $(A,\mathfrak m)$ is a commutative local ring and $M$ is a finitely generated projective $A$-module, then $M$ is free. Indeed, let $k=A/\mathfrak m$ be the residue field, and choose elements $x_1,\dots,x_r\in M$ whose images form a $k$-basis of $M/\mathfrak m M$. Define the $A$-[linear map](/page/Linear%20Map)
\begin{align*}
\alpha:A^r\to M
\end{align*}
by sending the $i$-th standard basis vector to $x_i$. By [Nakayama's lemma](/theorems/2935), $\alpha$ is surjective. Since $M$ is projective, the exact sequence
\begin{align*}
0\to \ker(\alpha)\to A^r\xrightarrow{\alpha}M\to 0
\end{align*}
splits, so $\ker(\alpha)$ is finitely generated. Reducing modulo $\mathfrak m$, the map $k^r\to M/\mathfrak m M$ is an isomorphism by construction, hence
\begin{align*}
\ker(\alpha)/\mathfrak m\ker(\alpha)=0.
\end{align*}
Nakayama's lemma gives $\ker(\alpha)=0$, so $\alpha$ is an isomorphism and $M\cong A^r$.
Third, we use the finite local-global projectivity criterion: if $M$ is a finitely generated $R$-module and there exist elements $f_1,\dots,f_N\in R$ generating the unit ideal such that each localization $M_{f_i}$ is a finite free $R_{f_i}$-module, then $M$ is a finitely generated projective $R$-module. Equivalently, finite locally free modules on the affine scheme $\operatorname{Spec}(R)$ are precisely finitely generated projective $R$-modules.
[guided]
The proof uses three local algebra principles, and it is important to separate their roles.
The first principle is that localization preserves the algebraic structure involved in projectivity. If $M$ is a direct summand of a finite free module, then there is an $R$-module $N$ and an integer $n\ge 0$ with
\begin{align*}
M\oplus N\cong R^n.
\end{align*}
For a multiplicative set $S\subset R$, exactness and compatibility of localization with finite direct sums give
\begin{align*}
S^{-1}M\oplus S^{-1}N\cong S^{-1}(R^n)\cong (S^{-1}R)^n.
\end{align*}
Thus $S^{-1}M$ is a direct summand of a finite free $S^{-1}R$-module.
The second principle is that finite projective modules over local rings are free. Let $(A,\mathfrak m)$ be a commutative local ring and let $M$ be a finitely generated projective $A$-module. Set $k=A/\mathfrak m$. Since $M$ is finitely generated, the $k$-[vector space](/page/Vector%20Space) $M/\mathfrak mM$ has a finite basis. Choose elements $x_1,\dots,x_r\in M$ whose images form such a basis, and define the $A$-linear map
\begin{align*}
\alpha:A^r\to M
\end{align*}
by sending the $i$-th standard basis vector of $A^r$ to $x_i$.
The induced map
\begin{align*}
k^r\to M/\mathfrak mM
\end{align*}
is an isomorphism by the choice of the elements $x_i$. In particular, the images of $x_1,\dots,x_r$ generate $M/\mathfrak mM$, so Nakayama's lemma implies that $x_1,\dots,x_r$ generate $M$ over $A$. Therefore $\alpha$ is surjective.
Because $M$ is projective, the surjection $\alpha:A^r\to M$ splits. Hence the short exact sequence
\begin{align*}
0\to \ker(\alpha)\to A^r\xrightarrow{\alpha}M\to 0
\end{align*}
is split exact, and $\ker(\alpha)$ is a direct summand of the finitely generated module $A^r$. Thus $\ker(\alpha)$ is finitely generated. Reducing the sequence modulo $\mathfrak m$, the map $k^r\to M/\mathfrak mM$ is an isomorphism, so the reduction of $\ker(\alpha)$ is zero:
\begin{align*}
\ker(\alpha)/\mathfrak m\ker(\alpha)=0.
\end{align*}
Applying Nakayama's lemma again to the finitely generated module $\ker(\alpha)$ gives $\ker(\alpha)=0$. Hence $\alpha$ is an isomorphism and $M\cong A^r$.
The third principle is the affine local-global criterion for finite projectivity. It says that a finitely generated module that is finite free on a finite principal open cover is projective. This is the step that converts local bases into a global direct-summand statement.
[/guided]
[/step]
[step:Show that finitely generated projective modules are locally free]
Assume that $P$ is projective. Since $P$ is finitely generated and projective, there exist an integer $n\ge 0$ and an $R$-module $Q$ such that
\begin{align*}
P\oplus Q\cong R^n.
\end{align*}
Let $\mathfrak p\in\operatorname{Spec}(R)$ be a prime ideal. Localizing at the multiplicative set $R\setminus\mathfrak p$, we obtain
\begin{align*}
P_{\mathfrak p}\oplus Q_{\mathfrak p}\cong R_{\mathfrak p}^n.
\end{align*}
Thus $P_{\mathfrak p}$ is a finitely generated projective module over the local ring $R_{\mathfrak p}$. By the local-ring fact proved above, there is an integer $r(\mathfrak p)\ge 0$ such that
\begin{align*}
P_{\mathfrak p}\cong R_{\mathfrak p}^{r(\mathfrak p)}.
\end{align*}
Since $P$ is a direct summand of the finite free module $R^n$, it is finitely presented. The isomorphism
\begin{align*}
P_{\mathfrak p}\cong R_{\mathfrak p}^{r(\mathfrak p)}
\end{align*}
therefore spreads from the stalk to some principal neighbourhood: there exists $f\in R\setminus\mathfrak p$ such that
\begin{align*}
P_f\cong R_f^{r(\mathfrak p)}.
\end{align*}
Hence $P$ is locally free.
[/step]
[step:Reduce local freeness to a finite principal cover]
Assume conversely that $P$ is locally free in the stated sense. For every prime ideal $\mathfrak p\in\operatorname{Spec}(R)$, choose an element $f_{\mathfrak p}\in R\setminus\mathfrak p$ and an integer $r(\mathfrak p)\ge 0$ such that
\begin{align*}
P_{f_{\mathfrak p}}\cong R_{f_{\mathfrak p}}^{r(\mathfrak p)}.
\end{align*}
The principal open sets
\begin{align*}
D(f_{\mathfrak p})=\{\mathfrak q\in\operatorname{Spec}(R):f_{\mathfrak p}\notin\mathfrak q\}
\end{align*}
cover $\operatorname{Spec}(R)$.
By quasi-compactness of $\operatorname{Spec}(R)$, there are prime ideals $\mathfrak p_1,\dots,\mathfrak p_N$ such that
\begin{align*}
\operatorname{Spec}(R)=D(f_{\mathfrak p_1})\cup\cdots\cup D(f_{\mathfrak p_N}).
\end{align*}
Set $f_i=f_{\mathfrak p_i}$ for $1\le i\le N$. The equality of these principal opens covering $\operatorname{Spec}(R)$ is equivalent to the ideal $(f_1,\dots,f_N)$ being the unit ideal. For each $i$, there is an integer $r_i\ge 0$ such that
\begin{align*}
P_{f_i}\cong R_{f_i}^{r_i}.
\end{align*}
[/step]
[step:Apply the finite local-global criterion to obtain projectivity]
The module $P$ is finitely generated by hypothesis, and the elements $f_1,\dots,f_N$ generate the unit ideal. Moreover, each localization $P_{f_i}$ is a finite free $R_{f_i}$-module. Therefore the finite local-global projectivity criterion applies and gives that $P$ is a finitely generated projective $R$-module.
This proves the converse implication. Combining it with the forward implication, $P$ is projective if and only if it is locally free in the Zariski topology.
[/step]