Let q and a be relatively prime. The idea is to show that there are infinitely many primes of the form a+qn by showing the sum
\sum \frac{1}{p}
diverges, where this sum is taken over primes p=a+qn for some value of n.
It involves using the Dirichlet L-functions,
L(s,\chi)=\sum_{n=1}^{\infty}\frac{\chi(n)}{n^s}
where \chi(n) is a multiplicative character from the multiplicative group (\mathbb{Z}/q\mathbb{Z})^\times to the complex numbers and extended to the naturals by periodicity and setting \chi(n)=0 if n and q are not relatively prime.
These satisfy some nice orhtogonality relations that let us pick out arithmetic progressions like the sum we are interested in. We can show, for s>1:
\sum\chi(a)\log L(s,\chi)=\phi(q)\sum\frac{1}{p^s}+O(1)
where the sum is taken over all characters mod q and the sum on the right is over all primes in our progression (phi is the usual euler phi function). When our character is trivial, L(s,\chi) behaves much like the usual zeta function, and diverges to infinity as s approaches 1. Therefore, if you can show that the rest of the L-functions in the left hand sum behave and don't vanish (i.e. their log's behave) then the sum on the right will diverge like we need.
The hard part turns out to be showing that \L(1,\chi) is non zero when \chi is a real character, that is it only takes on values in the real numbers (actually +1 or -1), but that's the basic outline.