[proofplan]
Let $\Lambda: \mathbb{N}\to\mathbb{R}$ denote the von Mangoldt function, and let $\chi_0: \mathbb{Z}\to\mathbb{C}$ denote the principal Dirichlet character modulo $q$. Define the ordinary Chebyshev function $\psi: [1,\infty)\to\mathbb{R}$ by $\psi(x)=\sum_{1\leq n\leq x}\Lambda(n)$, and define the Dirichlet $L$-function attached to $\chi$ on $\operatorname{Re}(s)>1$ by $L(s,\chi)=\sum_{n=1}^{\infty}\chi(n)n^{-s}$. For the principal character, $\chi_0$ removes exactly the prime powers whose prime base divides $q$, so $\psi(x,\chi_0)$ differs from $\psi(x)$ by at most $O_q(\log x)$; the [prime number theorem](/theorems/1742) for $\psi$ then gives $\psi(x,\chi_0)\sim x$. For a nonprincipal character, the Dirichlet series of $\Lambda(n)\chi(n)$ is the logarithmic derivative $-L'(s,\chi)/L(s,\chi)$ on $\operatorname{Re}(s)>1$. The local holomorphic continuation and boundary nonvanishing of nonprincipal Dirichlet $L$-functions, including imprimitive characters, make this logarithmic derivative holomorphic across the line $\operatorname{Re}(s)=1$, and the complex-coefficient Wiener-Ikehara theorem then gives $\sum_{n\leq x}\Lambda(n)\chi(n)=o(x)$.
[/proofplan]
[step:Compare the principal character sum with the ordinary Chebyshev function]
Assume first that $\chi=\chi_0$. Define the ordinary Chebyshev function $\psi: [1,\infty) \to \mathbb{R}$ by
\begin{align*}
\psi(x) := \sum_{1 \leq n \leq x} \Lambda(n).
\end{align*}
Since $\chi_0(n)=1$ when $\gcd(n,q)=1$ and $\chi_0(n)=0$ when $\gcd(n,q)>1$, we have
\begin{align*}
\psi(x)-\psi(x,\chi_0)
&= \sum_{\substack{1 \leq n \leq x \\ \gcd(n,q)>1}} \Lambda(n).
\end{align*}
The von Mangoldt function is supported on prime powers: $\Lambda(n)=\log p$ if $n=p^k$ for some prime $p$ and $k \in \mathbb{N}$, and $\Lambda(n)=0$ otherwise. Therefore only prime powers $p^k \leq x$ with $p \mid q$ contribute to the last sum. Hence
\begin{align*}
0 \leq \psi(x)-\psi(x,\chi_0)
&= \sum_{p \mid q}\sum_{\substack{k \in \mathbb{N} \\ p^k \leq x}} \log p \\
&= \sum_{p \mid q} \left\lfloor \frac{\log x}{\log p} \right\rfloor \log p \\
&\leq \sum_{p \mid q} \log x.
\end{align*}
If $\omega(q)$ denotes the number of distinct prime divisors of $q$, this gives
\begin{align*}
0 \leq \psi(x)-\psi(x,\chi_0) \leq \omega(q)\log x.
\end{align*}
Thus
\begin{align*}
\psi(x,\chi_0)=\psi(x)+O_q(\log x).
\end{align*}
[guided]
We isolate exactly what the principal character changes. The map $\chi_0: \mathbb{Z}\to\mathbb{C}$ is the indicator of the residue classes coprime to $q$: it equals $1$ on integers $n$ with $\gcd(n,q)=1$ and equals $0$ otherwise. Thus $\psi(x,\chi_0)$ is the ordinary Chebyshev sum with the terms not coprime to $q$ removed.
Define
\begin{align*}
\psi: [1,\infty) &\to \mathbb{R} \\
x &\mapsto \sum_{1 \leq n \leq x} \Lambda(n).
\end{align*}
Then
\begin{align*}
\psi(x)-\psi(x,\chi_0)
&= \sum_{\substack{1 \leq n \leq x \\ \gcd(n,q)>1}} \Lambda(n).
\end{align*}
The von Mangoldt function vanishes except at prime powers. More precisely, $\Lambda(n)=\log p$ when $n=p^k$ for a prime $p$ and an integer $k \in \mathbb{N}$, and $\Lambda(n)=0$ otherwise. If $\gcd(p^k,q)>1$, then necessarily $p \mid q$. Hence the difference is exactly bounded by summing over prime powers whose prime base divides $q$:
\begin{align*}
0 \leq \psi(x)-\psi(x,\chi_0)
&= \sum_{p \mid q}\sum_{\substack{k \in \mathbb{N} \\ p^k \leq x}} \log p.
\end{align*}
For a fixed prime $p$, the condition $p^k \leq x$ is equivalent to $k \leq \log x/\log p$, so the number of such $k$ is $\left\lfloor \log x/\log p \right\rfloor$. Therefore
\begin{align*}
\sum_{\substack{k \in \mathbb{N} \\ p^k \leq x}} \log p
= \left\lfloor \frac{\log x}{\log p} \right\rfloor \log p
\leq \log x.
\end{align*}
Summing over the finitely many prime divisors of $q$ gives
\begin{align*}
0 \leq \psi(x)-\psi(x,\chi_0) \leq \omega(q)\log x,
\end{align*}
where $\omega(q)$ is the number of distinct prime divisors of $q$. This is precisely
\begin{align*}
\psi(x,\chi_0)=\psi(x)+O_q(\log x).
\end{align*}
[/guided]
[/step]
[step:Use the classical prime number theorem for the principal character]
By the classical [prime number theorem](/theorems/1692) in Chebyshev form (citing a result not yet in the wiki: Prime Number Theorem for the Chebyshev Function),
\begin{align*}
\psi(x) \sim x.
\end{align*}
Since $\log x=o(x)$, the estimate from the preceding step gives
\begin{align*}
\frac{\psi(x,\chi_0)}{x}
= \frac{\psi(x)}{x}+O_q\left(\frac{\log x}{x}\right)
\to 1.
\end{align*}
Thus $\psi(x,\chi_0)\sim x$.
[/step]
[step:Identify the Dirichlet series for a nonprincipal character]
Assume now that $\chi \neq \chi_0$. Define the Dirichlet $L$-function
\begin{align*}
L(\,\cdot\,,\chi): \{s \in \mathbb{C} : \operatorname{Re}(s)>1\} &\to \mathbb{C} \\
s &\mapsto \sum_{n=1}^{\infty}\frac{\chi(n)}{n^s}.
\end{align*}
On $\operatorname{Re}(s)>1$, the Euler product is absolutely convergent and gives
\begin{align*}
L(s,\chi)=\prod_p \left(1-\frac{\chi(p)}{p^s}\right)^{-1}.
\end{align*}
Taking the logarithmic derivative of the absolutely convergent Euler product gives
\begin{align*}
-\frac{L'}{L}(s,\chi)
&= \sum_p \sum_{k=1}^{\infty} \frac{\chi(p)^k\log p}{p^{ks}}.
\end{align*}
Because a Dirichlet character is completely multiplicative and $\Lambda(p^k)=\log p$, this double series is exactly
\begin{align*}
-\frac{L'}{L}(s,\chi)
= \sum_{n=1}^{\infty}\frac{\Lambda(n)\chi(n)}{n^s}
\end{align*}
for every $s \in \mathbb{C}$ with $\operatorname{Re}(s)>1$.
[guided]
The purpose of this step is to connect the summatory function $\psi(x,\chi)$ with a complex analytic object. For $\operatorname{Re}(s)>1$, define
\begin{align*}
L(\,\cdot\,,\chi): \{s \in \mathbb{C} : \operatorname{Re}(s)>1\} &\to \mathbb{C} \\
s &\mapsto \sum_{n=1}^{\infty}\frac{\chi(n)}{n^s}.
\end{align*}
Since $|\chi(n)|\leq 1$ for every $n\in\mathbb{N}$, this series converges absolutely on $\operatorname{Re}(s)>1$. The usual Euler product for Dirichlet characters therefore holds in this half-plane:
\begin{align*}
L(s,\chi)=\prod_p \left(1-\frac{\chi(p)}{p^s}\right)^{-1}.
\end{align*}
The product is absolutely convergent there, so taking logarithms and differentiating term by term is justified in $\operatorname{Re}(s)>1$. This gives
\begin{align*}
-\frac{L'}{L}(s,\chi)
&= \sum_p \frac{\chi(p)\log p\,p^{-s}}{1-\chi(p)p^{-s}} \\
&= \sum_p \sum_{k=1}^{\infty} \frac{\chi(p)^k\log p}{p^{ks}}.
\end{align*}
Now we translate this double sum into a single Dirichlet series. Since $\chi$ is completely multiplicative, $\chi(p^k)=\chi(p)^k$. Since $\Lambda$ is supported on prime powers and satisfies $\Lambda(p^k)=\log p$, the coefficient attached to $p^{-ks}$ is precisely $\Lambda(p^k)\chi(p^k)$. Therefore
\begin{align*}
-\frac{L'}{L}(s,\chi)
= \sum_{n=1}^{\infty}\frac{\Lambda(n)\chi(n)}{n^s}
\end{align*}
for every $s$ with $\operatorname{Re}(s)>1$.
[/guided]
[/step]
[step:Extend the logarithmic derivative holomorphically across the boundary line]
Since $\chi$ is nonprincipal, the standard [analytic continuation](/page/Analytic%20Continuation) theorem for Dirichlet $L$-functions gives the following local statement: for every point $s_0 \in \mathbb{C}$ with $\operatorname{Re}(s_0)=1$, the function $L(\,\cdot\,,\chi)$ extends holomorphically to an open neighbourhood of $s_0$. This applies also when $\chi$ is imprimitive. Indeed, if $\chi_1$ is the primitive character modulo $q_1$ inducing $\chi$, then
\begin{align*}
L(s,\chi)=L(s,\chi_1)\prod_{\substack{p\mid q \\ p\nmid q_1}}\left(1-\frac{\chi_1(p)}{p^s}\right)
\end{align*}
on $\operatorname{Re}(s)>1$, and the finite product gives the continuation. For $\operatorname{Re}(s)=1$, each extra factor is nonzero because
\begin{align*}
\left|\chi_1(p)p^{-s}\right|\leq p^{-1}<1,
\end{align*}
so $1-\chi_1(p)p^{-s}\neq 0$. The boundary nonvanishing theorem for nonprincipal Dirichlet $L$-functions says that this continuation has no zeros at points with $\operatorname{Re}(s)=1$ (citing a result not yet in the wiki: Nonvanishing of Dirichlet $L$-Functions on the Line $\operatorname{Re}(s)=1$). Hence, for every such $s_0$, there is an open neighbourhood $V_{s_0}\subset\mathbb{C}$ such that $L(s,\chi)\neq 0$ for all $s\in V_{s_0}$ and $L(\,\cdot\,,\chi)$ is holomorphic on $V_{s_0}$. Therefore
\begin{align*}
s \mapsto -\frac{L'}{L}(s,\chi)
\end{align*}
is holomorphic on $V_{s_0}$. Thus the Dirichlet series
\begin{align*}
\sum_{n=1}^{\infty}\frac{\Lambda(n)\chi(n)}{n^s}
\end{align*}
has a holomorphic continuation to a neighbourhood of every point on the boundary line $\operatorname{Re}(s)=1$.
[guided]
The Tauberian theorem we will use needs analytic continuation up to and across the boundary line $\operatorname{Re}(s)=1$. The previous step identified the Dirichlet series as $-L'/L$ only in the half-plane $\operatorname{Re}(s)>1$, so we now verify that this quotient has no singularity on the boundary.
Because $\chi$ is nonprincipal, the analytic continuation theorem for Dirichlet $L$-functions gives local holomorphic continuation at every point of the line $\operatorname{Re}(s)=1$. If $\chi$ is imprimitive and is induced by a primitive character $\chi_1$ modulo $q_1$, then $L(s,\chi)$ is obtained from $L(s,\chi_1)$ by multiplying by finitely many Euler factors corresponding to primes dividing $q$ but not $q_1$:
\begin{align*}
L(s,\chi)=L(s,\chi_1)\prod_{\substack{p\mid q \\ p\nmid q_1}}\left(1-\frac{\chi_1(p)}{p^s}\right).
\end{align*}
These factors are holomorphic near $\operatorname{Re}(s)=1$. They also have no zeros on the line itself: if $\operatorname{Re}(s)=1$, then
\begin{align*}
\left|\chi_1(p)p^{-s}\right|\leq p^{-1}<1,
\end{align*}
so $1-\chi_1(p)p^{-s}\neq 0$. Thus the same local continuation and boundary nonvanishing statements apply to imprimitive nonprincipal characters. The boundary nonvanishing theorem for nonprincipal Dirichlet $L$-functions states that this continuation satisfies $L(s,\chi)\neq 0$ whenever $\operatorname{Re}(s)=1$ (citing a result not yet in the wiki: Nonvanishing of Dirichlet $L$-Functions on the Line $\operatorname{Re}(s)=1$).
Fix a point $s_0\in\mathbb{C}$ with $\operatorname{Re}(s_0)=1$. Since $L(s_0,\chi)\neq 0$ and $L(\,\cdot\,,\chi)$ is holomorphic near $s_0$, continuity gives an open neighbourhood $V_{s_0}\subset\mathbb{C}$ on which $L(s,\chi)\neq 0$. On this neighbourhood the quotient
\begin{align*}
s \mapsto -\frac{L'}{L}(s,\chi)
\end{align*}
is holomorphic, because it is the quotient of two holomorphic functions with nonvanishing denominator. Combining this with the identity
\begin{align*}
-\frac{L'}{L}(s,\chi)
= \sum_{n=1}^{\infty}\frac{\Lambda(n)\chi(n)}{n^s}
\end{align*}
on $\operatorname{Re}(s)>1$, we obtain the required holomorphic continuation of the Dirichlet series across every point of the line $\operatorname{Re}(s)=1$.
[/guided]
[/step]
[step:Apply the complex-coefficient Tauberian theorem]
Define the coefficient sequence $a: \mathbb{N}\to\mathbb{C}$ by
\begin{align*}
a(n):=\Lambda(n)\chi(n).
\end{align*}
Then $|a(n)|\leq \Lambda(n)\leq \log n$ for $n\geq 2$, and the Dirichlet series
\begin{align*}
A(s):=\sum_{n=1}^{\infty}\frac{a(n)}{n^s}
\end{align*}
converges for $\operatorname{Re}(s)>1$. By the preceding steps,
\begin{align*}
A(s)=-\frac{L'}{L}(s,\chi)
\end{align*}
on $\operatorname{Re}(s)>1$, and $A$ extends holomorphically to a neighbourhood of every point of $\operatorname{Re}(s)=1$. We invoke the complex-coefficient Wiener-Ikehara theorem in its logarithmic-growth Dirichlet-series form (citing a result not yet in the wiki: Complex Wiener-Ikehara Theorem). This form states that if $A(s)=\sum_{n=1}^{\infty}a(n)n^{-s}$ converges on $\operatorname{Re}(s)>1$, the coefficients satisfy $|a(n)|\leq C\log n$ for all $n\geq 2$, and $A$ extends holomorphically to a neighbourhood of every point of the line $\operatorname{Re}(s)=1$, then $\sum_{1\leq n\leq x}a(n)=o(x)$. Here these hypotheses hold with $C=1$, and there is no pole at $s=1$. Therefore the theorem gives
\begin{align*}
\sum_{1 \leq n \leq x} a(n)=o(x).
\end{align*}
Substituting $a(n)=\Lambda(n)\chi(n)$ yields
\begin{align*}
\psi(x,\chi)=\sum_{1 \leq n \leq x}\Lambda(n)\chi(n)=o(x).
\end{align*}
This proves the nonprincipal case and completes the proof.
[/step]