From Gibbon's 'Decline and Fall' Chapter 68:
From the first hour of the memorable twenty-ninth of May, disorder and rapine prevailed in Constantinople till the eighth hour of the same day, when the sultan himself passed in triumph through the gate of St. Romanus. He was attended by his vizirs, bashaws, and guards, each of whom (says a Byzantine historian) was robust as Hercules, dexterous as Apollo, and equal in battle to any ten of the race of ordinary mortals. The conqueror gazed with satisfaction and wonder on the strange though splendid appearance of the domes and palaces, so dissimilar from the style of Oriental architecture. In the hippodrome, or atmeidan, his eye was attracted by the twisted column of the three serpents; and, as a trial of his strength, he shattered with his iron mace or battle-axe the under jaw of one of these monsters, which in the eyes of the Turks were the idols or talismans of the city. At the principal door of St. Sophia he alighted from his horse and entered the dome; and such was his jealous regard for that monument of his glory, that, on observing a zealous Musulman in the act of breaking the marble pavement, he admonished him with his scimitar that, if the spoil and captives were granted to the soldiers, the public and private buildings had been reserved for the prince. By his command the metropolis of the Eastern church was transformed into a mosque: the rich and portable instruments of superstition had been removed; the crosses were thrown down; and the walls, which were covered with images and mosaics, were washed and purified, and restored to a state of naked simplicity. On the same day, or on the ensuing Friday, the muezin, or crier, ascended the most lofty turret, and proclaimed the esan, or public invitation, in the name of God and his prophet; the imam preached and Mohammed the Second performed the namaz of prayer and thanks giving on the great altar, where the Christian mysteries had so lately been celebrated before the last of the Caesars.
... In the new character of a mosque, the cathedral of St. Sophia was endowed with an ample revenue, crowned with lofty minarets, and surrounded with groves and fountains for the devotion and refreshment of the Moslems The same model was imitated in the jami, or royal mosques; and the first of these was built by Mohammed himself, on the ruins of the church of the holy apostles and the tombs of the Greek emperors.
Hagia Sophia was Mehmed's by right of conquest and not purchase.