Offloading tasks to the mobile ad hoc cloud (MAHC) can improve the utility of mobile devices in scenarios without infrastructure. However, when multiple resource demanders (RDs) offload tasks to multiple resource providers (RPs) in the MAHC with task random generation, how to optimize the utility of RDs and the service quality of the MAHC is an issue worth researching. To this end, we investigate this issue from the stochastic game perspective. Firstly, we combine the obtained time, energy, and monetary revenue as the utility of each RD and construct the utility improvement of each RD as a static non-cooperative game. Secondly, according to the randomness of RD’s task generation, we transform the single-shot non-cooperative game into a stochastic game in an infinite time horizon to obtain the long-term utility. Thirdly, to reduce the computational complexity for achieving Nash equilibrium, we propose an action reduction alternate backward iteration algorithm according to the games characteristics and prove its convergence. Finally, we compare the utility obtained from the static game with the stochastic game, the numerical results indicating that the utility of each RD can be effectively improved by utilizing the stochastic game.