  The classical Brun--Titchmarsh theorem gives an upper bound, which is of
correct order of magnitude in the full range, for the number of primes
$p\leqslant x$ satisfying $p\equiv a\bmod q$. We strength this inequality for
$\log q/\log x$ in different ranges, improving upon previous works by
Motohashi, Goldfeld, Iwaniec, Friedlander and Iwaniec, and Maynard for general
or special moduli. In particular, we obtain a Burgess-like constant in the full
range $q<x^{1/2-}.$ The proof is based on various estimates for character and
exponential sums, by appealing to arithmetic exponent pairs and bilinear forms
with algebraic trace functions from $\ell$-adic cohomology, and sums of
Kloosterman sums from spectral theory of automorphic forms, as well as large
value theorem for Dirichlet polynomials due to Huxley.
