The Jefferson Market Library is one of the most iconic structures in Greenwich Village, and it opened its doors (and its rooftop views of the surrounding neighborhood) to the public this weekend as part of Open House New York.

Photographer Sai Mohktari took the tour and snapped some photos of the historic building, which is located at 425 Sixth Avenue near West 10th Street. It was designed as a courthouse by architects Frederick Clark Withers and Calvert Vaux (who also assisted in the design of Central Park) in a Victorian Gothic style. The structure was built—along with an adjacent prison and market—between 1875-1877, cost the city almost $360K, and was immediately voted one of the ten most beautiful buildings in America by a poll of architects in the 1880s. (Back then, it was known as Third Judicial District Courthouse.)

The basement, which has brick arches and low ceilings, was originally used as a holding area for prisoners on their way to jail or trial. The building got substantial use as a courthouse in the early 20th century, popping up in several famous cases, including the trial of Harry K. Thaw for the murder of architect Stanford White; that case later became immortalized in E.L. Doctorow's Ragtime. In the 1920s, it was used mainly for the trails of women; Mae West was locked up there after being arrested on obscenity charges when her Broadway play Sex became a target of the Society for the Suppression of Vice.

After 1945, the building was in danger of being torn down, but a group of local preservationists—including E.E. Cummings and Lewis Mumford—who started the very catchily-named "Committee of Neighbors to Get the Clock on Jefferson Market Courthouse Started." In 1961, the New York Public Library agreed to convert it into a library; it reopened in 1967 after an estimated $1.4 million renovation, with the police court becoming the Children's Reading Room, and the civil court becoming the Adult Reading Room.

Click through to check out photos from around the building, including the gorgeous Village views of the neighborhood (you can see the green rooftop at PS41 from there), the main library, and the balcony, which is where their giant Halloween puppet spider lives year-round (along with some octopus tentacles that were discarded remnants from an old Broadway show). As is tradition, the spider will be hung from one of the turrets on the tower on Halloween, and people can act as puppeteers, moving its limbs.