The aisles at Fairway are still populated with shoppers scooping European olives from the olive bar, spooning coffee beans from giant barrels and grabbing organic apples from piles of fresh produce.

So it came as a shock to the New York grocer’s legion of fiercely loyal shoppers on Thursday when Fairway announced it had filed for Chapter 11 bankruptcy and would sell some of its 14 stores to Village Super Market. Just the day before, Fairway had played down reports of a possible bankruptcy.

But Fairway, a beloved New York fixture since the 1930s, had been in financial trouble for years.

Over the past quarter century, Fairway rapidly and ambitiously expanded beyond its modest flagship store on the Upper West Side of Manhattan with visions of dominating the regional New York City market.

There were numerous missteps, though: costly leases at struggling stores; fierce competition from less expensive rivals like FreshDirect, Trader Joe’s and Amazon Fresh; and a takeover by private equity in 2007 that fueled complaints about rising prices and diminishing quality.