Derivation of relationship between equilibrium constant and Gibbs free energy change
Using the fundamental equations for the state function (and its natural variables): 
\begin{align}
  \mathrm{d}G &amp;= -S\mathrm{d}T + V\mathrm{d}P\\
  V &amp;= \left(\frac{\partial G}{\partial P}\right)_T\\
  \bar{G}(T,P_2) &amp;= \bar{G}(T,P_1) + \int_{P_1}^{P_2}\bar{V} \mathrm{d}p
\end{align}
Here $\bar{x}$ represents molar $x$, i.e. $x$ per mole
\begin{align}
  \bar{V} &amp;= \frac{RT}{P}\\
  \bar{G}(T,P_2) &amp;= \bar{G}(T,P_1) + RT \ln\frac{P_2}{P_1}
\end{align}
Defining standard state as $P = \pu{1 bar}$ and $\bar{G}=\mu$
$$\mu(T,P)=\mu^\circ (T) + RT\ln \frac{P}{P_o}$$
consider the general gaseous reaction $\ce{a A + b B -&gt; c C + d D}$
$$\Delta G=(c\mu_\ce{C} + d\mu_\ce{D} - a\mu_\ce{A} - b\mu_\ce{B})$$
for "unit progress" in reaction. Using $\mu_i = \mu^\circ_i + RT\ln \frac{P_i}{\pu{1 bar}}$
\begin{align}
\Delta G &amp;= (c\mu^\circ_\ce{C} + d\mu^\circ_\ce{D} - a\mu^\circ_\ce{A} - b\mu^\circ_\ce{B}) + RT \ln\frac{P_\ce{C}^c P_\ce{D}^d}{P_\ce{A}^a P_\ce{B}^b}\\
\Delta G &amp;= \Delta G^\circ + RT\ln Q
\end{align}