He attended the University of Toulouse before moving to Bordeaux in the second half of the 1620s. In Bordeaux he began his first serious mathematical researches and in 1629 he gave a copy of his restoration of Apollonius's Plane loci to one of the mathematicians there. Certainly in Bordeaux he was in contact with Beaugrand and during this time he produced important work on maxima and minima which he gave to Étienne d'Espagnet who clearly shared mathematical interests with Fermat.
From Bordeaux Fermat went to Orléans where he studied law at the University. He received a degree in civil law and he purchased the offices of councillor at the parliament in Toulouse. So by 1631 Fermat was a lawyer and government official in Toulouse and because of the office he now held he became entitled to change his name from Pierre Fermat to Pierre de Fermat.
For the remainder of his life he lived in Toulouse but as well as working there he also worked in his home town of Beaumont-de-Lomagne and a nearby town of Castres. From his appointment on 14 May 1631 Fermat worked in the lower chamber of the parliament but on 16 January 1638 he was appointed to a higher chamber, then in 1652 he was promoted to the highest level at the criminal court. Still further promotions seem to indicate a fairly meteoric rise through the profession but promotion was done mostly on seniority and the plague struck the region in the early 1650s meaning that many of the older men died. Fermat himself was struck down by the plague and in 1653 his death was wrongly reported, then corrected:-
I informed you earlier of the death of Fermat. He is alive, and we no longer fear for his health, even