It is a wellknown fact that if an integer is a sum of two rational squares then it is a sum of two integer squares. For example, Cohen vol. 1 page 314 prop. 5.4.9. Cohen gives a short proof that relies on HasseMinkowski, but he attributes the theorem (without reference) to Fermat, who didn't have HasseMinkowski available. So my question is, how did Fermat prove this theorem? and part 2 of the question is, what is the simplest direct proof? I googled for this result and found a manuscript with a proof that doesn't use HasseMinkowski, but it's not very short.
This result is pretty shy of needing the full HasseMinkowski Theorem. Indeed, since Fermat already knew which integers were a sum of two integer squares, it would suffice for him to show that those that weren't (i.e., those with an odd power of some prime congruent to 3 mod 4 showing up in its prime factorization) could also not be written as a sum of two rational squares. But this is the easy direction of HasseMinkowski: To show that (let's say) a prime $p\equiv 3\pmod{4}$ can't be written as a sum of two rational squares, it suffices to check that it can't be a sum of two $\ell$adic rational squares for some $\ell$. Of course, Fermat did not have the language of the $\ell$adics, so this would have had been replaced with mod$q^k$ conditions for various $k$. Specifically, the modern HasseMinkowski proof boils down to the statement that a prime which is 3 mod 4 can't be written as a sum of two rational squares because it can't be done so 2adically. Indeed, one can just compute the single Hilbert symbol $$ p\equiv 3\pmod{4}\Rightarrow (p,1)_2=(1)^{(p1)/2}=1, $$ showing that $x^2=pz^2y^2$ has no $2$adic, and hence no rational, solutions, which afte the substitutions $a=x/z$ and $b=y/z$, implies one cannot write $p=a^2+b^2$ with $a,b\in\mathbb{Q}$. Of course (again), Fermat did not have Hilbert symbols, but this is just a change of language away from Fermat's approach (I imagine). It would not be hard to unwind the above calculation into a single (probably lengthy) mod8 calculation, since that's all that goes into deciding which elements of $\mathbb{Q}_2$ are squares, which in turn is essentially all that lives behind the Hilbert symbols. 


Dear Michael, concerning your first question, I think that Franz's proof is really in the spirit of Fermat's techniques. Concerning the second question, here is a short, elementary proof, inspired by a theorem of Thue (cf. exercice 1.2 in Franz's book Reciprocity laws). I tried to write it using only notions known to Fermat. We want to prove that if there exist positive integers $m,n,a$ and $b$ such that $$m^2n=a^2+b^2,$$ then $n$ is itself the sum of two integer squares. It is easily seen that it is sufficient to prove this assertion under the hypothesis that $a$ and $b$ (and therefore $a$ and $n$) are coprime and that $n$ is not a square. Let $t$ be the unique positive integer such that $t^2< n<(t+1)^2$. Since there are $(t+1)^2>n$ integers of the form $au+bv$ with $0\leq u,v\leq t$, it follows that $n$ divides the difference $a(uu')+b(vv')$ of two of them. Setting $x=uu'$ and $y=vv'$, we have the inequalities $x,y\leq t$. The integer $n$ then divides $a^2x^2b^2y^2$; since it also divides $a^2y^2+b^2y^2$, it divides their sum, which is equal to $a^2(x^2+y^2)$. Now, the integers $a$ and $n$ being coprime, it follows that $n$ divides $x^2+y^2$. The inequalities $0< x^2+y^2<2n$ finally imply that $n=x^2+y^2$. 


In his early days, Fermat realized that a natural number that can be written as a sum of two rational squares actually is a sum of two integral squares, but he did not come back to this claim when eventually he discovered the proof of the TwoSquares Theorem. The result in question can be proved with the methods available to Fermat, as I will show here. Theorem 1 If $n$ is a sum of two rational squares, then every prime $q = 4n+3$ divides $n$ an even number of times. Theorem 2 Every prime number $p = 4n+1$ is the sum of two integral squares. Now we invoke the product formula for sums of two squares $$ (a^2 + b^2)(c^2 + d^2) = (acbd)^2 + (ad+bc)^2. $$ It implies that every product of prime numbers $4n+1$ and some power of $2$ can be written as a sum of two integral squares, and multiplying through by squares of primes $q = 4n+3$, the claim follows. Proof of Theorem 1 We will show that primes $p = 4n+3$ do not divide a sum of two coprime squares. Assume that $p \mid x^2 + y^2$ with $\gcd(x,y) = 1$. Reducing $x$ and $y$ modulo $p$ we may assume that $p/2 < x, y < p/2$; cancelling possible common divisors we then have $p \mid x^2 + y^2$ with $\gcd(x,y) = 1$ and $x^2 + y^2 < \frac12 p^2$. If $x$ and $y$ are both odd, then the identity $$ \Big(\frac{x+y}2\Big)^2 + \Big(\frac{xy}2\Big)^2 = \frac{x^2+y^2}2 $$ allows us to remove any remaining factor of $2$ from the sum, and we may therefore assume that $a^2 + b^2 = pr$ for some odd number $r < p$. Since $a$ and $b$ then have different parity, $a^2 + b^2$ must have the form $4n+1$, and therefore the number $r$ must have the form $4n+2$. But then $r$ must have at least one prime factor $q \equiv 3 \bmod 4$, and since $a^2 + b^2 < p^2$, we must have $q \le r < p$. Thus if $p \equiv 3 \bmod 4$ divides a sum of two coprime squares, then there must be some prime $q \equiv 3 \bmod 4$ less than $p$ with the same property. Applying descent we get a contradiction. Proof of Theorem 2
Lemma Assume that $pm = x^2 + y^2$ for coprime integers $x, y$, and let $q$ be a prime dividing $m$, say $m = qm_1$. If $q = a^2 + b^2$ is a sum of two squares, then $pm_1 = x_1^2 + y_1^2$ is also a sum of two squares. Applying this lemma repeatedly we find that if every $q \mid m$ is a sum of two squares, then so is $p$ in contradiction to our assumption. Thus there is a prime $q = 4k+1$, strictly smaller than $p$, which is not a sum of two squares, and now descent takes over. It remains to prove the Lemma. To this end, we have to perform the division $\frac{x^2+y^2}{a^2+b^2}$. By the product formula $$ (a^2+b^2)(c^2+d^2) = (acbd)^2 + (bc+ad)^2 $$ we have to find integers $c, d$ such that $x = acbd$ and $y = bc+ad$. Since $q \mid (a^2 + b^2)$ and $q \mid (x^2 + y^2)$ we also have $$ q \mid (a^2+b^2)x^2  (x^2+y^2)b^2 = a^2x^2  b^2y^2 = (axby)(ax+by). $$ Since $q$ is prime, it must divide one of the factors. Replacing $b$ by $b$ if necessary we may assume that $q$ divides $axby$. We know that $q$ divides $a^2 + b^2$ as well as $pm = x^2 + y^2$, hence $q^2$ divides $(ax  by)^2 + (ay+bx)^2 $ by the product formula. Since $q$ divides the first summand, it must divide the second as well, and we have $pm_1 = (\frac{axby}q)^2 + (\frac{ay+bx}q)^2$. 


EDIT: there is an elementary trick to do this due to Aubry, it is Theorem 4 on page 5 of PETE. The positive primitive binary forms which give the easy Aubry trick showing rational implies integral are: $$ x^2 + y^2, x^2 + 2 y^2, x^2 + 3 y^2, x^2 + 5 y^2, $$ $$ x^2 + x y + y^2, x^2 + x y + 2 y^2, x^2 + x y + 3 y^2, $$ $$ 2 x^2 + 3 y^2, 2 x^2 + x y +2 y^2, 2 x^2 + 2 x y + 3 y^2. $$ Note that these are all "ambiguous," that is, equivalent to their "opposites." This is not an accident. Probably needs mention, for the property mentioned by the OP there is no difference between the sum of two squares and the sum of three squares... Right, I don't know about Fermat, but this phenomenon happens often enough. The first mention on MO is Intuition for the last step in Serre's proof of the threesquares theorem About my use of the word "phenomenon," it is necessary for the AubryCasselsDavenport trick to work that we have Pete's "Euclidean" condition, Must a ring which admits a Euclidean quadratic form be Euclidean? which is usually, for positive quadratic forms, referred to as a bound on the "covering radius" of the integral lattice under consideration. It took me a year or so to prove that Pete's condition implied that there could only be one class in that genus, A Priori proof that Covering Radius strictly less than $\sqrt 2$ implies class number one A complete list of positive forms that satisfy Pete's condition is at NEBE. A mild generalization of the condition, due to Richard Borcherds and his student, Daniel Allcock, applies to such forms as the sum of five squares. 


This is an easy consequence of the fact that if $p \equiv 3$ (mod 4) is a rational prime, then $p$ remains prime in the ring of Gaussian integers $\mathbb{Z}[i].$ Then it follows that if $a$ and $b$ are rational integers, the powers of $p$ dividing $a+bi$ and $abi$ (in $\mathbb{Z}[i]$ ) are equal. Hence if $n$ is an integer with $a^2 + b^2 = c^2 n$ for integers $a,b$ and $c,$ then the power of $p$ dividing $n$ is even. The fact that $p$ remains prime in $\mathbb{Z}[i]$ was (at least implicitly) known to Fermat. For if $p = (r +si)(t+ui)$ for integers $r,s,t$ and $u,$ then $p^2 = (r^2 +s^2)(t^2 + u^2).$ We can't have $p = r^2 + s^2$ since a sum of two integer squares is congruent to $0,1$ or $2$ (mod 4). Hence we must conclude that one of $r + si$ or $t +ui$ is a unit in $\mathbb{Z}[i]$, so $p$ does remain prime in $\mathbb{Z}[i].$ 

