In a letter to Gauss, on January 3, 1840 (Werke II), Dirichlet stated the unit theorem in the same version as he would later publish it, along with the comment that the proof was very easy and could be given on two or three pages. Indeed the proof he published in 1846 was little more than 2 pages long. In addition, the French version of his proof was contained in a letter to Liouville, and was published already in 1840. I think this shows convincingly [See the Edit below] that the problem he solved in the Sistine Chapel in 1844 was not related to the unit theorem.
On the other hand Kummer, in his talk to the memory of Dirichlet, said that Dirichlet worked out the class number formulas for the equivalence classes of forms corresponding to fields of the p-th roots of unity while he was in Italy; in fact his articles on units that Dirichlet published before his journey to Italy are directly related to problems showing up in such an investigation. When Dirichlet heard that Kummer was also working out the class number formulas for such fields, he decided not to publish anything on this subject.
Edit. I'd like to add a few quotations from Kummer's papers concerning Dirichlet's results obtained in Italy.
- 1844, De numeris complexis.
For most numbers $\lambda$, the investigation of all units is very difficult and requires particular principles, which so far we have not yet sufficiently examined. We may skip this question, however, since we have heard that recently Lejeune-Dirichlet in Italy, where his still dwells, has worked out fundamental theorems on these complex units that we eagerly expect him to publish soon.
- 1846, Zur Theorie der Zahlen
p. 324: This investigation on the real and ideal complex numbers is completly
identical to the classification of certain related forms of degree $\lambda-1$ in $\lambda-1$ variables, of which Dirichlet has found but not yet published the main results.
p. 325: I have so far not yet studied this area of the theory of complex numbers
in depth; in particular I have not yet worked out the determination of the true number of classes since I have heard by word of mouth that Dirichlet, using principles similar to those in his famous memoirs on quadratic forms, has already found this number.
- 1846, Zerlegung der Wurzeln der Einheit:
The complete determination of those powers of ideal numbers that become real, as well as the determination of the number of inequivalent ideal numbers, requires principles that differ essentially from those given in the present memoir. We do not discuss this important question any further since, as we have already mentioned, the publication of an article by Dirichlet is imminent in which he has completely solved this question for a closely related topic.
- Beweis des Fermatschen Satzes
Assume that (A) the class number of $K = {\mathbb Q}(\zeta_p)$ is not divisible
by $p$, and (B) that each unit in $K$ that is congruent to a rational
integer modulo $p$ is actually a $p$-th power in $K$. Then the equation
$x^p + y^p = z^p$ does not have nontrivial solutions in integers.
This article was presented to the Academy of Berlin by Dirichlet, who
added the following remark.
The truth of the second assumption of Kummer's astute proof may be
verified for each given value of $p$ using the general theory of
complex units, about which I have given a few hints in the report
from March 1846 and which will be published in one of the next few
volumes of Crelle's journal.
After I had proved that every unit may be represented by $\frac{\lambda-3}2$
fundamental units, which is the result analogous to the general solution
of Fermat's equation $x^2 - Dy^2 = \pm 1$, it was natural to follow
this analogy between quadratic and these higher forms by determining
the number of the latter forms by methods similar to those with which
the same question in the theory of quadratic forms was solved. This
investigation, to which Kummer referred at the beginning of his note,
was luckily completed three years ago with the help of a new principle
that was not necessary for the determination of the number of forms
of the second degree, and has led to a result that is remarkable in its
form and which is as simple as may be expected for a result that
encompasses forms of all degrees. The expression for the number for forms
of degree $\lambda-1$ that I have found, which, as may be expected by
the analogy with quadratic forms, contains the $\frac{\lambda-3}2$
fundamental units, provides us, as soon as these units are known, with
a method to verify assumption (A) by a rather simple numerical calculation.
Edit (Oct. 2016) I retract my analysis above and claim the opposite: Dirichlet indeed did work out the general unit theorem during his stay in
Italy. In the preface to vol. I of Dirichlet's Collected Works, Kronecker writes
"Dirichlet read this memoir a year after his return from Italy, but the
fundamental and far-reaching investigations about which he made a few
remarks there he had completed - as I have learned from himself - already
during his stay in Italy."
And in Dirichlet's article "On the theory of units", the last one in vol. I of his Collected Works, he writes
"For the degrees after the second this theorem could be proved without
great problems, and we have presented the result concerning the third
degree in an earlier communication (Monatsbericht October 1841)
several years ago. The proof of the theorem in its full generality, which
we have found by induction, was obstructed by the greatest difficulties
that could be overcome completely only after many fruitless attempts.
Continued occupation with this problem then allowed me to simplify the
proof to such an extent that its prinicpal moments may be given in a
comprehensible manner in just a few words."
What follows is a description of how to construct the correct number of independent solutions of the unit equation, and it seems that what had eluded him in his early investigations is the role that the regulator is playing in this construction. In his earlier articles Dirichlet announced the general unit theorem, but gave details of the proof only for cubic extensions without stating clearly that he did not have a proof in the general case.