Both the Hospitallers and the Templars were military orders formed almost simultaneously in order to fight in the Crusades. The Knights Templar had their origins in 1118 when a group of knights led by Hugh de Payens, all having taken religious vows of chastity and poverty, who escorted Christian pilgrims to Jerusalem. In reward for their services, the King of Jerusalem allowed them to lodge in the Al-Aqsa Mosque in Jerusalem. Because the mosque stood on the same site as the original Temple of Solomon, they became known as the Knights Templar. They received recognition from the Pope and raised significant sums of money from their services protecting pilgrims. Eventually they became very wealthy, and their significant presence in both Western Europe and the Levant made them ideally situated to serve as bankers, and indeed they loaned money for the Crusades themselves as well as to individual monarchs, including the king of France.
The Hospitallers had relatively similar origins. They were initially a religious order than ran a hospital for pilgrims in the Holy Land, and under the leadership of Gerard de Martigues, they expanded their mission to providing military protection for pilgrims. They became known as the Friars of the Hospital of Saint John of Jerusalem and also achieved recognition from the Pope in 1113. They grew in influence, and indeed became rivals of the Templars, against whom they fought a civil war in the midst of the Crusades. They never, however, achieved the wealth or political influence of their rival order. After the Crusades, they relocated to Malta, where they became known as the Knights of Malta. They still exist today in the form of the Knights of Saint John of Jerusalem, and maintain their mission of hospital work.