We consider the sub-Riemannian problem on the group of motions of three-dimensional space. Such a problem is encountered in the analysis of 3D images as well as in describing the motion of a solid body in fluid. Mathematically, this problem reduces to solving a Hamiltonian system, the vertical part of which is a system of six differential equations with unknown functions u1,...,u6. The most important for applications and at the same time the simplest case (u6 = 0) was early rigorously studied by the authors. There a solution to the system was found in explicit form. Namely, the extremal controls u1, ..., u5 were expressed via elliptic functions. Now, we consider the general case: u6 is an arbitrary constant. In this case, we obtain a solution to the 0system in an operator form. Although the explicit form of the extremal controls does not follow directly from these formulas (their calculation requires the inversion of some nontrivial operator), it allows us to construct an approximate analytical solution for a small parameter u6. Computer simulation shows a good agreement between the constructed analytical approximations and the solutions computed via numerical integration of the system.