Upon leaving Milan, Leonardo and Pacioli traveled to Mantua, where Leonardo worked briefly on a portrait of the generous if overbearing patron of the arts, Isabelle d'Este; he never finished the work, despite frequent and nagging letters from Isabelle over the course of the next five years.
In 1500, Leonardo continued to Venice. The 1499 French invasion of Lombardy and Sforza's attempt to mount a counter-attack out of exile had embroiled much of the Mediterranean coast in war. Venice itself was currently at war with the Ottoman Empire. Leonardo went to the Senate of Venice and offered his services as an engineer. He wanted to construct a kind of mobile dam that would allow Venetian forces to draw the Turks into the Isonzo river valley and then flood the valley, wiping out the enemy forces. The Senate did not act on his plan. He also had devised a diving apparatus, and wanted to initiate an underwater raid on the Ottoman fleet, drilling holes in the bottoms of their ships. His design was remarkably similar to modern scuba gear. Neither of these plans were ever acted on, and Leonardo was careful to keep the details of his designs secret, so as not to let them fall into the wrong hands.
By April, he had returned to Florence. He saw his father Ser Piero, who was by this time a wealthy man of 74, living with his fourth wife. Leonardo took up lodgings with the Servite friars of Florence, hoping to find a patron soon. He agreed to paint an altarpiece for the friars, but it took months for him to begin. In the meantime, he undertook several architectural projects, and continued work in his notebooks on the collapse of buildings and building materials.
The altarpiece for the friars was to be a painting of the Virgin and Saint Anne, following the then current vogue for St. Anne, Mary's mother; at the time there was much discussion of an apocryphal passage which claimed that St. Anne was also a virgin mother. By 1501, Leonardo had begun work on the cartoon, or preliminary drawing. The painting itself was never finished, although he worked on it from time to time over the years. This painting is perhaps more beautiful incomplete than it would be complete. The Virgin, bending down, sits with her mother St. Anne. Anne's face is dark and mysterious, as if she is going to tell the fate of Jesus, while Mary remains warm and content. Mary seems anxious to keep the Child with her, although the child seems to be already interested in tending "his flock."
In 1502, Leonardo finally got his chance to act as a military engineer. In 1502, Cesare Borgia (who Leonardo had probably met Leonardo in Milan), was commander of the pope's army. He had nearly subjugated all of central Italy, the Romagna. In the late summer of 1502, Borgia took on Leonardo as his chief military engineer. Leonardo traveled the Tuscan coast, inspecting fortifications and draining marshes. He then traveled all over the Romagna, finally ending up in Imola. There, Borgia set up his winter quarters. The city was heavily fortified as attack was expected.
At Imola, Leonardo probably met Niccolo Machiavelli, who he would see again in Florence the next year. Leonardo probably got along well with Borgia: both were both ambitious, illegitimate, unconventional men. In addtion to his official military duties, while at Imola Leonardo drew what is perhaps the first directly overhead map of a city. Typical maps of the time assumed a vantage from an angle, a bird's eye view.
Initially, Leonardo may have planned to return to Milan. Conventional wisdom of the time held that Sforza would regain power, but these hopes were dashed when the duke was betrayed by his Swiss mercenaries. Even if he was planning to return, Leonardo does not appear to have been overly loyal to the duke. After all, the Ottomans were attacking Venice at Sforza's bidding. Sforza wanted to distract Venice, an ally of France, while he tried to retake Lombardy. Nonetheless, Leonardo was eager to devise scientific methods to defeat the Turks and quickly win the war for Venice. He was careful not to let his designs fall into the hands of criminals, but he did not seem to care which side of the war used them. Similarly, Leonardo did not seem to mind working for Cesare Borgia, who was renowned as an incestuous, impious man who had liaisons with his sister, had his brother murdered, and held as much responsibility for the corruption of the church as anyone else. It seems Leonardo's prime loyalty was to science.
When Leonardo returned to Florence, he was 48 years old. He had achieved great fame, but very few of his goals. He was no more likely to finish a commission than the last time he was in Florence, as seen in the case of the Virgin and Child with Saint Anne and a Lamb. His father was still alive. The city had changed a great deal. The Medici family had temporarily lost power, and the religious zealot Fra Savonarola took power, impugning the Church for impiety and ordering the burning of all books he found sinful. Though Savonarola had been burned at the stake by the time Leonardo reached Florence, some still appreciated his thoughts. One wonders whether Leonardo felt more or less comfortable in the Florence of 1500 than in the Florence of 1482.