Born at Rome, he was graduated in 1617 and studied under the botanist Andrea Cesalpino (1519–1603). He was professor at Rome from 1597 until 1634, when he went to Messina. He laid out the botanical gardens at Messina in 1635, where he cultivated many exotic medicinal plants (now the Orto Botanico "Pietro Castelli" of the University of Messina). The botanist Paolo Boccone studied under Castelli there.
Castelli was equally distinguished as a botanist, chemist, and surgeon. He maintained the necessity for all physicians of studying anatomy, and declared in 1648 that he had dissected more than one hundred corpses.
The Dane Thomas Bartolinus (1616–1680) was led by Castelli's fame to visit him in Messina, in 1644, and speaks of his activity as a publicist. Castelli wrote no less than one hundred and fifty pamphlets. Among these there is one written in 1653 in answer to inquiries by Hieronymus Bardi of Genoa, wherein Castelli speaks of the cinchona plant and its curative properties in cases of malaria.
Castelli seems to have had but little knowledge of the cinchona, and no experience in its medicinal application. Still, the pamphlet is noteworthy as being the first Italian publication that mentions the cinchona.
Castelli died at Messina.