[proofplan]
We package the local hypotheses into the fixed-determinant deformation problem $\mathcal{D}$ and compare its universal deformation ring with the localized weight $2$ Hecke algebra. The residual modularity hypothesis supplies the maximal ideal of the Hecke algebra, and the local hypotheses ensure that both the given representation and the Hecke-valued representation are deformations of type $\mathcal{D}$. The external Taylor-Wiles $R=\mathbb{T}$ theorem, assumed applicable by the stated numerical Selmer hypotheses, identifies the universal deformation ring with the Hecke algebra. Specializing this Hecke algebra point gives a classical weight $2$ eigenform whose attached Galois representation is $\rho$ after extending scalars.
[/proofplan]
[step:Form the global deformation problem determined by the hypotheses]
Let $S$ be a finite set of primes containing $\ell$, the infinite prime, and every finite prime at which $\rho$ or $\bar{\rho}$ is ramified. Define $\mathcal{D}$ to be the fixed-determinant global deformation problem for $\bar{\rho}:G_{\mathbb{Q}}\to GL_2(k)$ with determinant $\chi\varepsilon_\ell$. For $p\in S$ with $p\ne\ell$, the local condition is the chosen Taylor-Wiles local deformation functor: unramified minimal deformations when the local type is minimal, and the specified semistable deformation functor when the level contains the corresponding semistable prime. At $p=\ell$, the local condition is the ordinary deformation functor or the finite flat deformation functor, according to the hypothesis. These local functors are represented by the corresponding local deformation rings, and the global functor consists of deformations whose restrictions to $G_{\mathbb{Q}_p}$ lie in these local functors for every $p\in S$.
Hypotheses 1, 3, 4, and 5 say exactly that $\bar{\rho}$ satisfies the representability hypotheses for this deformation problem and that $\rho$ is a deformation of type $\mathcal{D}$.
Let $R_{\mathcal{D}}$ denote the universal complete Noetherian local $\mathcal{O}$-algebra representing deformations of $\bar{\rho}$ of type $\mathcal{D}$. Let $\rho_{\mathcal{D}}:G_{\mathbb{Q}}\to GL_2(R_{\mathcal{D}})$ denote the universal deformation. Since $\rho$ satisfies the determinant and local conditions defining $\mathcal{D}$, the universal property of $R_{\mathcal{D}}$ gives a local $\mathcal{O}$-algebra homomorphism
\begin{align*}
\varphi_\rho:R_{\mathcal{D}}&\to \mathcal{O}
\end{align*}
such that the pushforward $\varphi_\rho\circ \rho_{\mathcal{D}}$ is isomorphic to $\rho$.
[guided]
The first task is to turn the hypotheses into the object on which the Taylor-Wiles method acts. Let $S$ be a finite set of primes containing $\ell$, the infinite prime, and every finite prime at which either $\rho$ or $\bar{\rho}$ is ramified. We define $\mathcal{D}$ to be the deformation problem for the residual representation $\bar{\rho}:G_{\mathbb{Q}}\to GL_2(k)$ with fixed determinant $\chi\varepsilon_\ell$, with the stated minimal unramified or semistable local condition at each prime $p\ne \ell$ in $S$, and with the stated ordinary or finite flat condition at $\ell$.
Why is $\rho$ a point of this deformation problem? Hypothesis 3 gives the fixed determinant $\det\rho=\chi\varepsilon_\ell$. Hypothesis 4 gives the required local condition at each finite prime $p\ne \ell$. Hypothesis 5 gives the required local condition at $\ell$. Hypothesis 1 gives absolute irreducibility of $\bar{\rho}$, which is the standard representability hypothesis for the deformation functor in this setting. Thus $\rho$ is a deformation of $\bar{\rho}$ of type $\mathcal{D}$.
Let $R_{\mathcal{D}}$ be the universal complete Noetherian local $\mathcal{O}$-algebra representing deformations of type $\mathcal{D}$, and let
\begin{align*}
\rho_{\mathcal{D}}:G_{\mathbb{Q}}&\to GL_2(R_{\mathcal{D}})
\end{align*}
be the universal deformation. The universal property means that every deformation of type $\mathcal{D}$ is obtained by pushing forward $\rho_{\mathcal{D}}$ along a unique local $\mathcal{O}$-algebra map from $R_{\mathcal{D}}$. Applying this to $\rho$ gives a local homomorphism
\begin{align*}
\varphi_\rho:R_{\mathcal{D}}&\to \mathcal{O}
\end{align*}
for which $\varphi_\rho\circ \rho_{\mathcal{D}}$ is isomorphic to $\rho$.
[/guided]
[/step]
[step:Use residual modularity to construct the matching Hecke algebra]
By Hypothesis 2, $\bar{\rho}$ arises from a weight $2$ cuspidal eigenform. Let $N_{\mathcal{D}}$ denote the tame level determined by the local conditions in $\mathcal{D}$, and let $\chi$ denote the finite-order nebentypus character from the determinant condition. Let $\mathbb{T}_{\mathcal{D}}$ be the completion at the maximal ideal $\mathfrak{m}_{\bar{\rho}}$ of the $\mathcal{O}$-subalgebra of endomorphisms of the weight $2$ cuspidal space of level $N_{\mathcal{D}}$ and nebentypus $\chi$ generated by the Hecke operators $T_p$ for primes $p\nmid N_{\mathcal{D}}\ell$ and the usual operators at primes dividing the level. The maximal ideal $\mathfrak{m}_{\bar{\rho}}$ is the ideal whose residue system of Hecke eigenvalues agrees with the characteristic polynomials of $\bar{\rho}(\operatorname{Frob}_p)$ for all primes $p\nmid N_{\mathcal{D}}\ell$.
We use the standard Deligne-Carayol construction of the Galois representation valued in a localized weight $2$ Hecke algebra. It gives a continuous representation
\begin{align*}
\rho_{\mathbb{T}}:G_{\mathbb{Q}}&\to GL_2(\mathbb{T}_{\mathcal{D}})
\end{align*}
whose residual representation is isomorphic to $\bar{\rho}$ and whose characteristic polynomial at every prime $p\nmid N_{\mathcal{D}}\ell$ is
\begin{align*}
X^2-T_pX+\chi(p)p.
\end{align*}
The determinant is therefore $\chi\varepsilon_\ell$, and the local-global compatibility built into the chosen Hecke algebra gives the same minimal, semistable, ordinary, or finite flat local conditions as those defining $\mathcal{D}$. Hence $\rho_{\mathbb{T}}$ is a deformation of $\bar{\rho}$ of type $\mathcal{D}$.
By the universal property of $R_{\mathcal{D}}$, there is a natural local $\mathcal{O}$-algebra homomorphism
\begin{align*}
\theta:R_{\mathcal{D}}&\to \mathbb{T}_{\mathcal{D}}
\end{align*}
such that $\theta\circ\rho_{\mathcal{D}}$ is isomorphic to $\rho_{\mathbb{T}}$.
[guided]
Residual modularity is what lets us put the residual representation inside a Hecke algebra. By Hypothesis 2, $\bar{\rho}$ occurs modulo the maximal ideal attached to a weight $2$ cuspidal eigenform. The deformation problem $\mathcal{D}$ determines a tame level $N_{\mathcal{D}}$ and the determinant condition determines the nebentypus $\chi$. We define $\mathbb{T}_{\mathcal{D}}$ to be the completion at the maximal ideal $\mathfrak{m}_{\bar{\rho}}$ of the weight $2$ cuspidal Hecke algebra of level $N_{\mathcal{D}}$ and nebentypus $\chi$. The ideal $\mathfrak{m}_{\bar{\rho}}$ is specified by the congruences between Hecke eigenvalues and the characteristic polynomials of $\bar{\rho}(\operatorname{Frob}_p)$ at primes $p\nmid N_{\mathcal{D}}\ell$.
The external input here is the Deligne-Carayol construction of Galois representations attached to localized weight $2$ Hecke algebras, together with local-global compatibility at the primes in the chosen level. It provides a continuous representation
\begin{align*}
\rho_{\mathbb{T}}:G_{\mathbb{Q}}&\to GL_2(\mathbb{T}_{\mathcal{D}})
\end{align*}
whose residual representation is $\bar{\rho}$ and whose characteristic polynomial at each prime $p\nmid N_{\mathcal{D}}\ell$ is
\begin{align*}
X^2-T_pX+\chi(p)p.
\end{align*}
This formula gives determinant $\chi\varepsilon_\ell$. The local-global compatibility statement ensures that the restrictions to decomposition groups at primes in $S$ satisfy exactly the local deformation conditions used to define $\mathcal{D}$. Therefore $\rho_{\mathbb{T}}$ is a deformation of type $\mathcal{D}$.
Since $R_{\mathcal{D}}$ represents deformations of type $\mathcal{D}$, the deformation $\rho_{\mathbb{T}}$ induces a unique local $\mathcal{O}$-algebra homomorphism
\begin{align*}
\theta:R_{\mathcal{D}}&\to \mathbb{T}_{\mathcal{D}}
\end{align*}
with $\theta\circ\rho_{\mathcal{D}}\cong\rho_{\mathbb{T}}$.
[/guided]
[/step]
[step:Apply the Taylor-Wiles $R=\mathbb{T}$ theorem to the comparison map]
We now invoke the Taylor-Wiles $R=\mathbb{T}$ theorem as an external input, not as the conclusion to be proved. In the form used here, it states that for a fixed-determinant deformation problem $\mathcal{D}$ satisfying absolute irreducibility, oddness, residual modularity, the Taylor-Wiles local deformation conditions, and the Taylor-Wiles numerical equality for the adjoint Selmer and dual Selmer groups, the canonical map from the universal deformation ring to the localized Hecke algebra is an isomorphism.
The hypotheses match our situation as follows. Hypothesis 1 gives absolute irreducibility and oddness of $\bar{\rho}$. Hypothesis 2 gives residual modularity. Hypothesis 3 fixes the determinant $\chi\varepsilon_\ell$. Hypotheses 4 and 5 say that the local deformation rings defining $\mathcal{D}$ are the Taylor-Wiles local rings away from $\ell$ and at $\ell$. Hypothesis 6 is precisely the required Selmer numerical criterion for $\operatorname{ad}^0(\bar{\rho})$ and its Tate-twisted dual. Therefore the external $R=\mathbb{T}$ theorem applies to
\begin{align*}
\theta:R_{\mathcal{D}}&\to \mathbb{T}_{\mathcal{D}}.
\end{align*}
It gives that $\theta$ is an isomorphism of complete local $\mathcal{O}$-algebras.
[guided]
The comparison map $\theta:R_{\mathcal{D}}\to \mathbb{T}_{\mathcal{D}}$ is the place where the deep Taylor-Wiles theorem enters. We are not proving the Taylor-Wiles patching theorem inside this proof. Instead, the theorem statement assumes the exact numerical hypotheses under which the external $R=\mathbb{T}$ theorem applies.
The external $R=\mathbb{T}$ theorem has the following input data: a residual representation $\bar{\rho}$ that is absolutely irreducible, odd, and modular; a fixed determinant; Taylor-Wiles local deformation conditions; and the numerical control of the adjoint Selmer group and its dual Selmer group needed for patching. These inputs are present here. Hypothesis 1 gives absolute irreducibility and oddness. Hypothesis 2 gives modularity of $\bar{\rho}$. Hypothesis 3 fixes the determinant as $\chi\varepsilon_\ell$. Hypotheses 4 and 5 specify the local deformation rings in the Taylor-Wiles list: minimal unramified or semistable away from $\ell$, and ordinary or finite flat at $\ell$. Hypothesis 6 states the Selmer numerical condition for $\operatorname{ad}^0(\bar{\rho})$ and $\operatorname{ad}^0(\bar{\rho})(1)$.
With these hypotheses verified, the Taylor-Wiles $R=\mathbb{T}$ theorem applies to the canonical map
\begin{align*}
\theta:R_{\mathcal{D}}&\to \mathbb{T}_{\mathcal{D}}.
\end{align*}
The conclusion is
\begin{align*}
R_{\mathcal{D}}&\cong \mathbb{T}_{\mathcal{D}}
\end{align*}
as complete local $\mathcal{O}$-algebras, and this isomorphism carries the universal deformation to the Hecke-valued Galois representation.
[/guided]
[/step]
[step:Specialize the Hecke algebra point to obtain the modular form giving $\rho$]
Since $\theta$ is an isomorphism, the homomorphism $\varphi_\rho:R_{\mathcal{D}}\to \mathcal{O}$ corresponds, after replacing $\mathcal{O}$ by the ring of integers $\mathcal{O}'$ in a finite extension if necessary, to a local $\mathcal{O}$-algebra homomorphism
\begin{align*}
\psi_\rho:\mathbb{T}_{\mathcal{D}}&\to \mathcal{O}'.
\end{align*}
Because $\mathbb{T}_{\mathcal{D}}$ is a localized quotient of the classical weight $2$ cuspidal Hecke algebra, any finite integral homomorphism from it to $\mathcal{O}'$ gives a classical system of Hecke eigenvalues. Equivalently, there exists a weight $2$ cuspidal eigenform $f$ of level $N_{\mathcal{D}}$ and nebentypus $\chi$ whose Hecke eigenvalues are obtained by applying $\psi_\rho$ to the universal Hecke operators. Let
\begin{align*}
\rho_f:G_{\mathbb{Q}}&\to GL_2(\mathcal{O}')
\end{align*}
be the $\ell$-adic Galois representation attached to $f$.
The construction of $\theta$ gives compatibility of the universal deformation with the Hecke-valued Galois representation. Applying $\psi_\rho$ to this compatibility gives
\begin{align*}
\rho_f&\cong \rho\otimes_{\mathcal{O}}\mathcal{O}'.
\end{align*}
Therefore $\rho$ is modular after extending scalars, as required.
[guided]
The isomorphism $R_{\mathcal{D}}\cong\mathbb{T}_{\mathcal{D}}$ converts the deformation point defined by $\rho$ into a Hecke eigensystem. More explicitly, the local homomorphism
\begin{align*}
\varphi_\rho:R_{\mathcal{D}}&\to \mathcal{O}
\end{align*}
corresponds, after a finite scalar extension if needed to contain the relevant eigenvalues, to a local homomorphism
\begin{align*}
\psi_\rho:\mathbb{T}_{\mathcal{D}}&\to \mathcal{O}'.
\end{align*}
Here $\mathcal{O}'$ is the ring of integers in a finite extension of the fraction field of $\mathcal{O}$.
Why does this homomorphism come from a classical modular form? The algebra $\mathbb{T}_{\mathcal{D}}$ was defined as a localized quotient of the classical weight $2$ cuspidal Hecke algebra. A homomorphism from this finite Hecke algebra to $\mathcal{O}'$ is exactly a system of eigenvalues for the Hecke operators on the corresponding cuspidal space. Therefore there is a weight $2$ cuspidal eigenform $f$ of level $N_{\mathcal{D}}$ and nebentypus $\chi$ whose eigenvalues are obtained from $\psi_\rho$.
Let
\begin{align*}
\rho_f:G_{\mathbb{Q}}&\to GL_2(\mathcal{O}')
\end{align*}
be the $\ell$-adic Galois representation attached to $f$. The map $\theta$ was defined so that pushing forward the universal deformation along $\theta$ gives the Hecke-valued Galois representation. Pushing forward once more along $\psi_\rho$ gives the specialization attached to $f$, while pushing forward along $\varphi_\rho$ gives $\rho$. Hence
\begin{align*}
\rho_f&\cong \rho\otimes_{\mathcal{O}}\mathcal{O}'.
\end{align*}
This is precisely modularity of $\rho$ after extending scalars.
[/guided]
[/step]