An active sonar track-before-detect algorithm is described. It is based on a hidden Markov model which uses a Viterbi algorithm to estimate the log-likelihood ratio of the presence or absence of a target in tracks within a state space representing a set of ranges, bearings, range rates and bearing rates, assuming a set of transition probabilities of changes in range rate and bearing rate. A detection is declared if the log-likelihood ratio exceeds a certain threshold and subsequently an HMM tracker, operating on a much smaller state space, is then employed. The performance of this algorithm on simulated data is evaluated. It is shown that, for moving and manoeuvring targets, the detection performance is significantly better than that of a conventional algorithm.