  We use product systems of $C^*$-correspondences to introduce twisted
$C^*$-algebras of topological higher-rank graphs. We define the notion of a
continuous $\mathbb{T}$-valued $2$-cocycle on a topological higher-rank graph,
and present examples of such cocycles on large classes of topological
higher-rank graphs. To every proper, source-free topological higher-rank graph
$\Lambda$, and continuous $\mathbb{T}$-valued $2$-cocycle $c$ on $\Lambda$, we
associate a product system $X$ of $C_0(\Lambda^0)$-correspondences built from
finite paths in $\Lambda$. We define the twisted Cuntz--Krieger algebra
$C^*(\Lambda,c)$ to be the Cuntz--Pimsner algebra $\mathcal{O}(X)$, and we
define the twisted Toeplitz algebra $\mathcal{T} C^*(\Lambda,c)$ to be the
Nica--Toeplitz algebra $\mathcal{NT}(X)$. We also associate to $\Lambda$ and
$c$ a product system $Y$ of $C_0(\Lambda^\infty)$-correspondences built from
infinite paths. We prove that there is an embedding of $\mathcal{T}
C^*(\Lambda,c)$ into $\mathcal{NT}(Y)$, and an isomorphism between
$C^*(\Lambda,c)$ and $\mathcal{O}(Y)$.
