Let R be a pid and let F be a free module over R with basis b. Let M be a submodule of F.
Well order the basis b, so that we can consider the basis elements b0 b1 b2 b3 etc in order. Yes, this requires the axiom of choice, unless b is countable, or can otherwise be well ordered.
For any ordinal j, let Fj be the free submodule of F spanned by b0 through bj. Let Mj be the intersection of Fj with M. Let Pj be the projection of Mj onto the jth copy of R.
Note that Pj is isomorphic to an ideal of R. Since R is a pid, let gj generate Pj. If gj = 0 there is nothing to do. If gj is nonzero, let uj be anything in Mj whose jth component is equal to gj. As we shall see, uj is a basis for M, whence M is free.
Let's demonstrate linear independence first. Suppose a finite linear combination ∑ cjuj = 0. Look at the last term, the largest j. Only uj contributes gj to the jth component. Thus cj has to be zero, which is a contradiction. The vectors uj are independent by construction. Each one brings in a component that was not there before, like vectors building a lower triangular matrix.
Suppose u does not span all of M. Every x that is not spanned, lies in some Mj, and naturally, x is not spanned by u0 through uj. Let j be the least ordinal such that u0 through uj does not span some x in Mj.
Write the jth component of x as sbj, for some s in R. If s is 0 then x belongs to a smaller Mj, hence s is nonzero. Write s as tgj. Let y = x-tuj. Now x is spanned by u1 through uj iff y is spanned. Yet y belongs to a lesser submodule Mi, below Mj. Therefore y is spanned, and so is x.
The arbitrary submodule M of F has a basis, and is free. Furthermore, the rank of M is less than or equal to the rank of F.