We provide an algorithm to solve the word problem in all fundamental groups of 3-manifolds that are either closed, or compact with (finitely many) boundary compo- nents consisting of incompressible tori, by showing that these groups are autostackable. In particular, this gives a common framework to solve the word problem in these 3-manifold groups using finite state automata. We also introduce the notion of a group which is autostackable respecting a subgroup, and show that a fundamental group of a graph of groups whose vertex groups are autostackable respecting any edge group is autostackable. A group that is strongly coset automatic over an autostackable subgroup, using a prefix-closed transversal, is also shown to be autostackable respec...