In this paper we consider a class of quasi-birth-and-death processes for which explicit solutions can be obtained for the rate matrix R and the associated matrix G. The probabilistic interpretations of these matrices allow us to describe their elements in terms of paths on the two-dimensional lattice. Then determining explicit expressions for the matrices becomes equivalent to solving a lattice path counting problem, the solution of which is derived using path decomposition, Bernoulli excursions, and hypergeometric functions. A few applications are provided, including classical models for which we obtain some new results.