That building is on a lot of people’s lists as their favorite in New York, or their favorite in Greenwich Village. It’s now the Jefferson Market Library, and was built in the 1870s as the Jefferson Market Courthouse. It’s one of the earliest successes of the preservation movement in the city, with the New York Public Library taking over the abandoned courthouse in 1961.
In the photo, Sixth Avenue is running diagonally down to the right, below the elevated train; West 10th Street is running away from our view, and the streetcar one block down 10th shows the line of Greenwich Avenue. The small triangular block defined by these three streets had a public food market starting in the 1830s and a small prison and courtrooms nearby. Here’s the early layout:
The “bell tower” was a fire-watch tower. The small buildings on the north (top) end of the block appear to have been privately owned. Here’s the view after the new courthouse was constructed on the site of those buildings, the new prison was constructed on the site of the old prison and police court, and a new market building constructed:
The yellow thing in the middle of Sixth Avenue, on the right, is a station for the elevated. Note also that the courthouse and prison were fire-proofed structure while the market was not. The prison and market were eventually torn down, having lost their purpose (like the courthouse) and not having any obvious reuse (unlike the courthouse). Their combined site is now the Jefferson Market Garden.
So, to summarize: first came the Jefferson Market. Then the Jefferson Market Courthouse and Jefferson Market Prison. The the courthouse was converted to the Jefferson Market Library, and the Jefferson Market Prison and Jefferson Market were converted to the Jefferson Market Garden.