Are finitely generated submodules of finitely generated free modules free? [duplicate]

Let $R$ be a commutative ring with identity. Then $R^n$ ($n$ is some positive integer) is a module over $R$ in a natural way. It is free and finitely generated. Now let $M$ be a finitely generated submodule of $R^n$. Does it follow that $M$ is free? My intuition leads me to believe that this is true, but I am not too sure.
This is false in general. For instance, in the polynomial ring $R=K[X,Y]$ ($K$ a field), the ideal $(X,Y)$ is a submodule of the free module $R$ which is not free since $\{X,Y\}$ is a minimal set of generators, but the satisfy the linear relation $YX-XY=0$.