In the 16th century the building was part of the defense system of the city. During the occupation by the Turks in 1672-1699 the synagogue was used as a mosque. The building was rebuilt and only in the 18th century was returned to the original view.
It is noteworthy that in Shargorod is not only the synagogue, but a quarter of the old Jewish houses.
More about the synagogue http://www.jta.org/2007/09/17/news-opinion/world/jewish-pearls-remain-in-south-ukraine