After his rebuff in Rome, Galileo returned to Florence, where he settled in the well-appointed villa of Bellosguardo, on a hill west of the city. His choice of residence was based, in part, on its proximity to a Franciscan convent, where two of his daughters had recently entered as nuns. (Their illegitimate birth deprived them of favorable marriage prospects, and so their acceptance by the convent provided a security they could not otherwise have hoped for.) Galileo was very close to his two daughters, particularly the eldest, Virginia, now known as Sister Mary Celeste, who would become a great support to him in his old age. Meanwhile, the Church's prohibitions had not diminished his intellectual fire, although for a time he channeled it into more minor pursuits, focusing on safer topics like magnets and motion, the construction of a microscope, and even plans for flood control in northern Italy. But his inability to explore his true interests wore on him, and for a time Galileo seems to have sunk into a deep depression, worsened by bouts of illness and hypochondria. Moreover, from 1617 to 1619, a series of terrible winters ruined the economy of Florence, making his gloomy predicament all the worse.

Eventually, however, his spirits revived; Galileo was soon fired up again in astronomical debate, as the August 1618 appearance of a magnificent comet sparked disagreement between his disciples and the Jesuit astronomers. While the Church scientists maintained that comets originated beyond the moon, Galileo's theory held (mistakenly) that they emanated from the earth's atmosphere. Now jumping personally into the fray, Galileo assisted one of his followers, Mario Guiducci, in writing a pamphlet objecting to the Jesuit view. The pamphlet employed such harsh language–referring to "absurdities" and "monstrosities" of their theory–that the Jesuits recoiled in bitter enmity. They responded to the Guiducci-Galileo treatise in harsh and cutting terms, thus inviting a counter-thrust from the proud Galileo. However, he waited two years before delivering it, composing in the meantime the 1622 treatise "The Assayer," which issued a rallying cry for what he believed to be the true path of scientific thought: "Philosophy is written in this grand book, the universe, which stands continually open to our gaze," he wrote. "But the book cannot be understood unless one first learns to comprehend the language and read the letters in which it is composed," he went on: "It is written in the language of mathematics, and its characters are triangles, circles, and other geometric figures... Without these, one wanders about in a dark and obscure labyrinth." In his heart, he was still the eager student at the University of Pisa, entranced by the glorious vistas of mathematics.

Meanwhile, political developments gave Galileo reason for a new optimism. September 1621 saw the death of Galileo's old nemesis, Cardinal Bellarmine. In January of that year, Pope Paul V had died as well, being replaced by the elderly Gregory XV, who passed away in turn in June of 1623. His successor was Urban VIII, a liberal churchman with a bent for science and a special fondness for Galileo.

At home in Bellosguardo, Galileo rejoiced at the election, and quickly dedicated "The Assayer" to the new Pope, who allowed it to be published and reportedly roared with laughter at Galileo's verbal tweaking of the Jesuits. Heartened, Galileo journeyed to Rome in April of 1624, and received warm welcome from Urban, who loaded him with gifts and praise–but refused to lift the Inquisition's ban on the Copernican theory. He and Galileo sparred over the issue, and his arguments seem to have stuck in Galileo's head, for he would put them in the mouth of a foolish character in his forthcoming work, the Dialogue Concerning the Two Chief World Systems. This would be a colossal blunder. For now though, Urban seemed to point the way to reconciliation when he declared that the Church had never "condemned nor ever would condemn the doctrine [of heliocentricity] as heretical, but only as rash." Galileo returned home in June, and, encouraged by the new leniency of Rome's position, set to work on what would become his masterpiece.

Galileo worked on the Dialogue Concerning the Two Chief World Systems intermittently over a period of five years, from 1624 to 1629. His labor encountered frequent interruptions, first in the form of persistent ill health and then by his temporary appointment to the ruling council of Tuscany under Cosimo II's son Ferdinand, but he persevered, and completed his labors. As its title suggests, the work took the form of a dialogue between three speakers: Salviati, a Copernican who speaks for Galileo himself; Sagredo, an open-minded gentleman who gradually comes to accept Salviati's arguments; and Simplicio, a defender of the Ptolemaic world-view, whose simplistic dogmatism falls to Salviati's keen insights. The dialogue form allowed him to claim impartiality– he was "equally" presenting both views–although in fact, of course, he clearly weighted the dialogue toward the Copernican point of view. Nevertheless, it seemed that the text would pass muster with the Catholic authorities: Galileo visited Rome in the spring of 1630, and obtained tentative permission for the publication of the Dialogue, on condition that certain changes be made, and that rigorous care be taken that the heliocentric theory be treated explicitly as a hypothesis. But now a plague swept Florence, and Galileo was called home; as disease descended upon northern Italy and communications broke down, Church authorities agreed that Galileo need not come to Rome for more revisions: the work could be published, as long as Galileo included an orthodox preface and conclusion, penned by the censors in Rome. The Dialogue was published according to orders in Florence in February 1632. It marked a great triumph for Galileo: his arguments for Copernicus's system stood in print at last, and with the blessing of the Church. But this triumph would be short-lived.