The word Khilafat means succession, and the Khalifa is a successor to a Prophet of Allah whose goal is to carry to completion the tasks of reformation and moral training that were seeded by the Prophet. The community of followers of a Prophet of Allah continues to nurture its faith and practices under the blessing of the institution of Khilafat for as long as Allah wishes. Allah says in the Holy Quran:
Allah had promised to those among you who believe and do good works that He will surely make them Successors in the earth, as He made Successors from among those who were before them; and that He will surely establish for them their religion which He has chosen for them; and that He will surely give them in exchange security and peace after their fear: They will worship Me, and they will not associate anything with Me. Then whoso is ungrateful after that, they will be the rebellious. (Surah Al-Nur, Verse 56).
Hazrat Mirza Bashir Ahmad(ra) writes:
God Almighty does everything through wisdom and foresight, and there is always a good reason and logic behind it. According to nature’s physical laws, man has only a limited life span, but the task of reformation and training of society requires a much longer time. So, Allah has established the system of Khilafat after the system of Prophethood. The Khalifah continues and carries on the task of the Prophet. The seed sown by the Prophet is protected and nurtured by the Khalifah till it becomes a strong and sturdy tree. It shows that in fact Khilafat is an offshoot or branch of the system of Prophethood, that is why the Holy Prophet(sa) says that after every Prophet, the system of Khilafat is established. (taken from Welcome to Ahmadiyyat).
Just as Allah appoints a Prophet, it is He who appoints a Khalifa as well. He chooses the person who is most eligible to become a Khalifa, and guides a group of pious believers into manifesting His Will through a process of selection of the Khalifa. Thus, it may apparently seem that the Khalifa is chosen by a group of pious people, but it is in fact the Will of Allah that guides their faculties into choosing the Khalifa of His Choice. Once a Khalifa is selected, he remains a Khalifa for the rest of his life as a living testament to Divine Will.
Khilafat establishes the authority of Allah on earth, and the Khalifa strives to uphold that authority within the community of followers. For the believers, Khilafat is an embodiment of Allah’s Unity, as they choose to take divine authority through the person of the Khalifa. The believers partake of the blessings of Khilafat by holding firm to their faith and practices, united under him.