A place of refuge from the hostility of their countrymen was now open to the rising sect. All the Moslems who were able and willing gradually found their way to Medina. At length none of the intending emigrants remained at Mecca but the prophet himself and his two friends Abu Bakr, and Ali. The designs of the Korayschites against Mahomet's life failed, and he effected his escape to a cave at some little distance from Mecca, and in the opposite direction from Medina. Here he remained in concealment with Abu Bakr for three days, the daughter of the latter bringing food for both. After this time a guide brought three camels with which they proceeded in safety to Medina. The prophet reached Koba, a village just outside it, on the 14th of September 622. He remained here three days, and received the visits of his adherents in Medina every day. This was the celebrated Hegira, or flight, from which the Mussulman era is dated.
In the course of a year, the majority of the inhabitants of Medina had adopted Islam, and a little later those who remained heathens were either compelled or persuaded to embrace, or at least to submit to, the new creed and its apostle. The Jews alone retained their ancient religion. But while Mahomet was thus successful with Medina, he was still exposed to the bitter hostility of Mecca. War between the two cities was the result of the hospitality accorded to him by the former. Mahomet, who now united in his person the temporal and spiritual supremacy in his adopted home, did not shrink from the contest, but carried it on with vigor and success. In the year 624, having gone in pursuit of a Meccan caravan, he met the army of the Korayschites at Badr, and defeated them; although he had not much more than three hundred men, while they commanded from nine hundred to one thousand. In the following year indeed the Moslems were defeated in the battle of Ohod; but in 627 the siege of Medina, undertaken by Abu Sofyân at the head of ten thousand men, was raised after three weeks without serious loss on either side.
Notwithstanding the enmity of its inhabitants, Mecca still retained in the eyes of Mahomet and his disciples its ancient prerogative of sanctity. The Kibla, or point towards which the Moslem was to turn in prayer, had for a time been Jerusalem; but Mahomet had restored this privilege to his native town two years after the Hegira. There too was the sacred stone, no less venerated by the pious worshiper of Allah than by the adherents of Lat, Ozza and Manah; and thither it was that the religious pilgrimage had to be performed, for Mahomet had no intention of giving up this part of his ancestral faith. He was desirous in the spring of 628 of performing the pilgrimage to Mecca. The Koreish, however, came out to meet him with an army, determined to preclude his entrance to the city. The design was therefore abandoned; but an important treaty was concluded between Mahomet and Sohayl, who acted as envoy from Mecca. By this compact both parties agreed to abstain from all hostilities for ten years; Mahomet was to surrender fugitives from Mecca, but the Meccans were not to surrender fugitives from him; no robbery was to be practiced; it was open to any one to make an alliance with either party; Mahomet and his followers were to be permitted to enter Mecca for three days in the following year for the festival. After making this agreement Mahomet, yielding to circumstances, performed the ceremonies of the festival at Hodaybiya near Mecca and then withdrew.
The treaty caused great dissatisfaction among the Moslems, as well it might; and the humiliation was heightened when the prophet, shortly after making it, was compelled to fulfil its provisions by giving up certain proselytes who had fled to him, from Mecca. Nevertheless his power continued to grow, and a tribe residing near Mecca took advantage of the treaty to conclude an alliance with him.
Mahomet now began to place himself on a level with crowned heads. In 628 he had a seal made with the inscription upon it: "Mahomet the messenger of God." Furnished with this official seal, he despatched six messengers with letters to the Emperor Heraclius; to the King of Abyssinia; to the Shah of Persia; to Mokawkas, lord of Alexandria; to Harith the Ghassanite chief; and to Hawda in Yamama, a province of Arabia. The purport of all these missives was an exhortation to the various sovereigns and chiefs to embrace the new religion, and a promise that God would reward them if they did, with a warning that they would bear the guilt of their subjects if they did not.
In the same year Mahomet besieged the town of Chaybar, whose inhabitants were Jews. Many of them were killed; the rest were permitted to withdraw with their families. Kinana, their chief, was executed; and his wife Cafyya was added to the already numerous harem of the victor.
The following year, 629, witnessed the performance by the Moslems of the pilgrimage to Mecca for the first time since the Hegira. The prophet summoned those who had accompanied him to Hodaybiya the year before to go with him now. The Koreish, according to the stipulations of the treaty, left the city; the Moslems entered it, performed their devotions, and retired after three days. This year was also marked by a signal victory over a Ghassanite chief, who had executed a Mussulman envoy.
In January, 630, taking advantage of the invitation of an allied tribe who had quarreled with Mecca, Mahomet quitted Medina with a large army for the purpose of taking that city. The exploit was facilitated by the desertion of the general of the Koreish, Abu Sofyân, who privately escaped to the Moslem camp and made his confession of faith. Next day the forces of the prophet entered Mecca with scarcely any resistance. In the following year he laid down the terms upon which the conquered city was to be dealt with. Abu Bakr, accompanied by 300 Moslems, was sent to Mecca as leader of the pilgrims. Ali was charged to make the proclamation to the people which is found in the 9th Sura of the Koran.
"An Immunity from God and his Apostle to those with whom ye are in league, among the Polytheist Arabs! (those who join gods with God). Go ye, therefore, at large in the land four months: but know that God ye shall not weaken; and that those who believe not, God will put to shame—And a proclamation on the part of God and his Apostle to the people on the day of the greater pilgrimage, that God is free from any engagement with the votaries of other gods with God as is his Apostle! If therefore ye turn to God it will be better for you; but if ye turn back then know that ye shall not weaken God: and to those who believe not, announce thou a grievous punishment. But this concerneth not those Polytheists with whom ye are in league, and who shall have afterwards in no way have failed you, nor aided any one against you. Observe, therefore, engagement with them through the whole time of their treaty: for God loveth those who fear him. And when the sacred months are passed, kill those who join other gods with God wherever ye shall find them; and seize them, besiege them, and lay wait for them with every kind of ambush: but if they shall convert, and observe prayer, and pay the obligatory alms, then let them go their way, for God is gracious, merciful. If any one of those who join gods with God ask an asylum of thee, grant him an asylum, that he may hear the Word of God, and then let him reach his place of safety. This, for that they are people devoid of knowledge" (K., p. 611.—Sura ix. 1-6).
Without quoting the proclamation at full length, we may observe that in substance the terms granted were these. Those of the heathen with whom treaties had been made were informed that they should be free for four months. These are the "sacred months" alluded to in the text, and which had always been observed as a time of truce by the heathen Arabs, but which Mahomet deprived of their privilege. After this period was past the Moslems might kill the heathens or take them prisoners wherever they might find them. With other heathens, with whom there was no treaty in existence, Allah announced that he would have nothing further to do. Moreover, the heathen were excluded by this proclamation from approaching the holy places of Mecca in future. "O believers!"—such are the words of this last decree—"only they who join gods with God are unclean! Let them not, therefore, after this year, come near the sacred Temple" (K., p. 615.—Sura ix. 28).