Peter then turned upon the Cossacks of the Don, who had shown greater independence than pleased him. Prince Dolgorouki to whom the task was confided of bringing them to order, wrote to the czar after he had destroyed the Cossack camp: "The chief rebels and traitors have been hung; of the others, one out of every ten; and all these dead malefactors have been laid on rafts, and turned into the river, to strike terror into the hearts of the Don people and to cause them to repent."
Mazeppa, as we have seen, was at this time hetman of the Cossacks of Little Russia. In his youth he had been a page of John Casimir, king of Poland; it was then that he had that terrible adventure which is connected indelibly with his name. After he was cut loose from the back of the unbroken horse that had carried him in the steppes, he entered among the Cossacks, and rose from the ranks by betraying every chief who helped him. Although it was Sophia who made him hetman, he was among the first to declare for Peter. His enemies, of whom he had many, accused him before the czar, but Peter admired him, and delivered his accusers up to him; they did not live long after Mazeppa had them in his power.
It was Mazeppa's scheme to establish an independent kingdom, he had the support of the Cossacks who did not care to work but preferred to be supported by the people. The industrious classes longed to get rid of this burden, and looked toward the czar to set them free. The tribute which Little Russia paid to Moscow was quite heavy, and when it was rumored that Peter was going to war with Sweden, Mazeppa thought this was an opportunity to carry out his scheme. He entered into negotiations with Stanislas Lecszinski whom Swedish influence had placed upon the throne of Poland. Peter was informed of this in detail, but he did not credit it, beheaded one of his informants, and the others, were tortured and sent to Siberia.
The war broke out, Charles XII, the romantic king of Sweden arrived in the neighborhood of Little Russia, and Peter called on Mazeppa to join the Russian army with his Cossacks. He pretended to be dying, but when the two hostile armies were drawing close, he crossed the Desna with his most trusted Cossacks to join the Swedes. Peter's eyes were opened; he gave orders to his general Menzikoff to take and sack Mazeppa's capital. This was done and Mazeppa's friends, who had remained behind, were executed. Mazeppa himself reached the Swedish camp. He was compelled to seek safety in Turkey, where he died miserably at Bender. His territory was annexed to Russia, the Cossacks lost all their privileges, and 1,200 of them were set to work on the Ladoga canal.
It was in 1700 that Peter, after concluding an alliance with Poland, determined to declare war against Sweden where young Charles XII had recently succeeded to the throne. Attacked at the same time by Russia, Poland, and Denmark, this young hero invaded the last-named country and compelled its king to conclude peace. After relieving Riga, Charles marched into Russia at the head of 8,500 men, and on the 30th of November defeated a Russian army of 63,000 men. This victory proved a misfortune, because it inspired the King of Sweden with contempt for Russian soldiers and made him careless, whereas Peter worked cheerfully and hard to profit from the lesson. While Charles was absent in Poland, his army was twice defeated.
Each of the two antagonists was worthy of the other's steel. Both were brave, but Charles was impetuous, whereas Peter acted upon cool judgment. The war continued until 1709 when Charles found himself in Little Russia, far away from supplies and reinforcements, in a Russian winter which happened to be exceptionally severe. In the spring he laid siege to Pultowa. The czar arrived on the 15th of June with 60,000 men; Charles had 29,000. On July 8, 1709, the battle of Pultowa was fought and Charles was defeated; he narrowly escaped being captured. With Mazeppa and the Pole Poniatowski, he made his way across the Turkish frontier, and remained until 1713, in the territory of the Sultan, whom he finally induced to declare war against Peter. This victory gave Peter the longed-for port on the Baltic, since Sweden was no longer in a condition to stop him.
What induced Sultan Ahmed III to risk war with Russia, was the hope of regaining Azof. Peter, on the other hand, hoped for an opportunity to capture Constantinople, the Czargrad of former times. He knew that he had the sympathy of the many Christians of the Greek Church, who were suffering under the yoke of the Turk. Trusting upon their support, Peter arrived on the bank of the Pruth with 38,000 exhausted soldiers. There he found himself surrounded by 200,000 Turks and Tartars. Peter gained a slight success, but not of sufficient importance to extricate or relieve him. Fearing an overwhelming calamity, Peter was prepared to make immense sacrifices in return for peace, and even to surrender Azof and the territory taken from Sweden, when his second wife Catherine had a happy thought. She collected all the money and jewels in the Russian camp, and sent them as a present to the Grand Vizier in command of the enemy, asking at the same time, what terms he would make. They were found unexpectedly reasonable: the surrender of Azof, the razing of the Russian forts erected on Turkish territory, and that Charles XII should be free to return to Sweden. Peter accepted eagerly, much as he regretted the loss of Azof and the failure of his schemes.
In 1713, a Russian fleet under Admiral Apraxine, with Peter serving under him as vice-admiral, captured several cities on the Baltic, and a Russian force entered north Germany. An alliance was formed against him and Peter decided to make an attempt at an alliance with France. In 1718, just as peace was being concluded with Charles XII, the King of Sweden, died and war broke out anew, lasting until 1721, when, by the Peace of Nystad, Sweden surrendered to Russia Livonia, Esthonia, and part of Finland. Peter had his way: Russia had open ports.
Peter was greatly pleased, and Russia rejoiced with him. The senate and Holy Synod conferred upon him the titles of "the Great, the Father of his country, and Emperor of all the Russias." In 1722, Peter led an expedition to the Caspian Sea. He captured Baku and five other important towns. He died three years later, in 1725.