It is thought that Malayo-Polynesian islanders had outposts in the Comoros as early as the 700's C.E. Later influxes by Arab traders made the Comoros into a group of rival Islamic sultanates, unified only by Islam. The name "Comoros" comes from an Arabic word, kamar or kumr, which means moon, although this name was applied to Madagascar before the Comoros islands themselves acquired it. At least two separate legends tell of Arab and Persian kingdoms being established in the Comoros, the former by two Arab families after Solomon's death and the latter at some point during the 11th century C.E. by a great Persian king. Bantu farmers from the mainland (probably around Mozambique) began to settle the islands by the fourteenth century, encountering the first group of Malayo-Polynesian colonists on the island of Nzwani and then moving on to establish settlements on Njazidja. These groups accepted Islam not too long thereafter from Arab traders with whom they had contact.
A major influx of Sunni Muslims from the city of Shiraz in modern-day Iran proved to be a major influence on later cultural and legal trends. Legends are told of seven Shirazi brothers who went about establishing colonies all around the Indian Ocean at about this time, and when all was said and done the island of Nzwani had been subdivided into two sultanates and Njazidja into eleven, while Mwali and Mahore were officially colonized as part of the Comoros at this time, too. In addition to setting the political stage by forming administrative units in the archipelago, the Shirazi are said to have brought stone architecture, carpentry, fruit cultivation, the Persian solar calendar, and cotton weaving to the Comoros, in addition to turning it into a major trading center for products bound for the Near East.
The Portugese, who landed on Njazidja in 1505, were the first Europeans to land in the Comoros. 22 years later, the Comoros start to appear on European maps, with Portugese Diogo Roberos' maps being the first. The Portugese tell of rich trade being carried out between Comoros, Madagascar, and the African mainland, and of vicious infighting over said trade between the many rival sultans of the Comoros. Possibly in response to increased European presence in the area, slave trading became increasingly important to the Comoros' economy. The Comoran sultans themselves began to take on slaves. In 1785, the Sakalava kingdom of western Madagascar began slaving raids on the Comoros to supply French plantations on islands in the Indian Ocean, nearly depopulating the nearest island to Madagascar, Mahore. Although the Comorans asked anyone and everyone for help, no respite came until the Merina of central Madagascar conquered the Sakalava kingdom and repopulated Mahore with his own subjects. Prosperity eventually returned, and by 1865 it was estimated that about 40% of the Comoran population were slaves imported from the mainland.
The governmental disunity among the Comoros Islands led to the French moving in during the 19th century. The French acquired Mahore after having lost their Indian Ocean ports to Britain in 1814. The group of islands eventually became a French protectorate in 1886 and an official colony as of 1912, when the last sultan abdicated. The French did their best to isolate these islands from the rest of the planet, maintaining an iron grip on the local political situation. The 1869 opening of the Suez Canal meant trade could now bypass the Comoros, so France began to treat the place like a source of tropical cash crops, instead of a vital trading center. Political organization and even newspaper publication was forbidden on a local level, and infrastructural development was very much inhibited by France's economic marginalization of the archipelago. It wasn't until December of 1961 that the islands were given even a small measure of autonomy. It still wasn't exactly democratic, and there was a wave of student protests against the French in 1968 that eventually led to the French allowing the formation of political parties. Said parties formed relatively quickly, and each one had a different idea as to what the country should do: some favored independence, some favored client state status, and one party based on the island of Mahore, the Mouvement Populaire Mahorais (MPM), didn't want independence at all. Despite the nation's divided mind as to its next course of action, in 1972 the pro-independence parties won the majority of the seats in the legislature with 34, while the MPM wound up with only five. It was into this climate that the French introduced their proposal
for independence. They offered to allow independence after five years and only after an island-by-island referendum had been taken. Although the legislature approved, the people did not, and they didn't treat the French Colonial Secretary very well when he popped in in September 1973.
The process was resultingly sped up, and a referendum for independence was held in December of 1974. Although about 94% of the voting public was in favor, about 65% of the island of Mayotte was not. Their representatives rejected independence, but were ignored by the remainder
of the islands, who announced their independence under the leadership of Ahmed Abdallah on July 6, 1975. Despite the conflicted nature of the country, the Organization for African Unity accepted the Comoros as a member on July 18 of that year.
Ahmed Abdallah was deposed not long after assuming power by Ali Solih, who ascended to a somewhat shaky hold on power on August 3, 1975. He was in turn re-deposed by Ahmed Abdallah with the help of some white mercenaries led by a fellow named Bob Denard on May 13, 1978. Those mercenaries helped Abdallah to consolidate power more effectively than his opponent, but caused the Comoran representative to be kicked out of the Organization for African Unity conference in 1978, since Comoros' neighbors weren't into mercenaries. They also didn't like Abdallah's fairly repressive regime, which outlawed political organization like the French had done before him. Although the country's membership with the OAU was reinstated in February of the following year, the mercenaries and the oppressive leadership style both stayed until the unpopular Abdallah's murder on November 27, 1989 by members of his own armed forces.
After that, theoretically power fell to Said Mohammed Djohar, who was going to try to hold free elections within 40 days. In fact, though, the mercenaries under Bob Denard were the only thing approaching real power in the Comoros. The French, however, came to the rescue, and Denard surrendered to them in December 1989. Free elections were held the following March, and Said Mohammed Djohar was elected president for six years with about 55% of the vote. Denard wasn't done, however. He was exonerated of the killing of Abdallah by the French government, and in 1995 he returned to the islands to try once again to take over. After a week of fighting, Djohar lay dead and Denard had been suppressed by French troops from the island of Reunion. Things didn't really calm down until 1996, when elections were held and a new Islamic government under Abdulkarim Taki gained power. The islands of Anjoun and Moheli disliked this turn of events enough to secede from the country in August 1997. Taki died a year later and was replaced by Ben Said Massounde, who was in turn overthrown in 1999 by the chief of the army, Col. Azzali Assumani. The newly established military government worked on a constitution for two years before a new one was finally approved that allowed each island greater autonomy within the Comoros government. It was approved in December 2001, and in May 2002 Col. Assumani was declared president after a delay due to a disputed election.
Sources: http://www.arab.net/comoros/history/comoros_history.html, http://www.countryreports.org/history/comorhist.htm, http://www.travel-guide.com/data/com/com580.asp