The Sidna Omar mosque is located right next to the Ramban and Hurva synagogues, two of the oldest synagogues in Jerusalem.
The surprising answer, as it turns out, is that it was built by Jews. [The answer might be less surprising when we consider that most of our troubles are caused by in-fighting and Jews colluding with our enemies]
None other than the Bartneura (Rabbi Obadiah of Bertinoro), tells us the story of the mosque, in a letter he wrote shortly after arriving in Jerusalem in 1488 (Available online here, the translation is based on Brachae Slae's translation):
"In the synagogue courtyard, very close by, is a Moslem mosque. This site originally belonged to a Jew who converted to Islam as a result of a quarrel with his fellow Jews. When his mother saw that her sons had converted because of the vexation the Jews had caused him, she dedicated her home in the synagogue courtyard as a Moslem place of worship as an act of revenge upon the Jews. This is what has caused all the harm, destroyed the synagogue, and made the Jewish community suffer such a financial loss. Had the merciful Lrd not put it into the king's heart to take pity on the Jews, no Jews would remain in Jerusalem."In this paragraph the Bartneura encapsulates the story of the Jewish community of Jerusalem in the 15th century. It was a difficult time for the Jews of Israel, but one also filled with great promise. The fall of Constantinople and the Byzantine empire, the wars by the Kingdom of Beta Israel against Christian Ethiopia, led many to believe that Redemption was near.
The story of the mosque and synagogue starts in the early 15th century. At the turn of the century the Jews of Jerusalem built a new synagogue, to be used for both the Ashkenazi and Sephardi communities. They of course had to pay off the Mamaluk rules to allow them to build it. The Ashkenazi community also bought a courtyard in that area.
Around the time the Ottomans conquered Constantinople (1453), the Jews of Jerusalem were forced to pay a great sum of money, convert to Islam or risk expulsion.
The story was written down by Rabbi Avraham Halevi Parnas, an emissary from Jerusalem to Europe [See Kovetz Al Yad 5, p45-50]. The letter he carried tells, in a manner very reminiscent of the Purim story, how the communities of Israel had to pay 100,000 gold florins to pay off the Mamaluk rulers. In Jerusalem they paid 10,000 gold florins, and the community had to sell off almost everything they had: hundreds of books and Torah scrolls, silver and gold Torah ornaments, as well as community-owned land. For the rest, they had to borrow at high interest.
The Bartenura, who was very critical of the way the community elders sold off all that was holy, explains that the Sultan, needing money for his wars, had demanded money from everybody in his kingdom, Jews, Christians and Muslims. The Jews of Egypt had also been forced to pay thousands of florins.
In any case, for years afterwards the Jerusalem community struggled to pay off remaining debts and additional taxes, which led to financial difficulties for all members. The wealthy and scholarly fled the city.
In the early 1470s, a house inside the synagogue complex collapsed. The Muslims wanted to add its yard to the mosque. The case came to the Muslim courts, where the judges denied the request.
“But,” added the Muslim plaintiffs, “the synagogue is new, and should not even exist according to Muslim law.”
The courts continued to investigate, and the issue went all the way up to Sultan Kait Bey. The Jews had to admit that the courtyard had been bought 70-80 years earlier. One of the plaintiffs didn’t wait for a verdict. Inciting fellow Muslims to act, a mob destroyed the synagogue.
Kait Bey got upset and issued an edict that the synagogue should be rebuilt, and the attackers punished.
When the courts finally ruled on the matter, the Jews were forced to pay hefty fines, and, of course, the (re)-building expenses. Once again the Jews had to borrow at high interest, and the financial burden increased.
As if all that wasn’t enough, earthquakes, plagues and drought afflicted the residents of Israel throughout the century.
When the Bartnerua came to Jerusalem in 1488, the community, a fraction of what it was earlier that century, still owed 1000 gold florins.
The Bartenura managed to renegotiate the tax burden, attract people to Jerusalem, re-open a yeshivah, and take the first steps to rejuvenate the community.
[This post is based mainly on "For the Sake Of Jerusalem" (Aharon Bier, translated by Brachae Slae), and "The history of Eretz Israel Under the Mamaluk and Ottoman Rule (1260-1804)" (Ben-Zvi Institute)]