Local action of the fundamental group SO(a, 4 + k − a) is used to show that any solution of an algebraically closed differential system, that is generated from matrix Lie algebra valued 1-forms on a four-dimensional parameter space, will generate families of immersions of four-dimensional spacetimes R4 in flat (4 + k)-dimensional spaces M4+k with compatible signature. The algorithm is shown to work with local action of SO(a, 4 + k − a) replaced by local action of GL(4 + k). Immersions generated by local action of the Poincaré group on the target spacetime are also obtained. Evaluations of the line elements, immersion loci and connection and curvature forms of these immersions are algebraic. Families of immersions that depend on one or more arbitrary functions are calculated for 1 ⩽ k ⩽ 4. Appropriate sections of graphs of the conformal factor for two and three interacting line singularities immersed in M6 are given in appendix A. The local immersion theorem given in appendix B shows that all local solutions of the immersion problem are obtained by use of this method and an algebraic extension in exceptional cases.