Let's call this a Tale of the Little Supermarket Chain That Couldn't, and then Could — thanks to federal regulators and a thing called competition.

McCaffrey's Supermarkets, a three-store operation founded 26 years ago in Bucks County by a South Philadelphia native named James J. McCaffrey III, took a shot at acquiring two Genuardi's Family Markets earlier this year when owner Safeway Inc. said it was selling the popular chain with 27 locations across the region.

McCaffrey, 60, was in talks to buy a Genuardi's in Newtown and one in Doylestown when, with little warning, talks ended. Bigger suitors, clearly, had come along, leaving little McCaffrey's in the deal Dumpster.

Then came a phone call in April from Carlisle-based heavy hitter Giant Food Stores. Giant had struck a deal to buy 16 Genuardi's stores, including the one in upscale Newtown that would have been perfect for the gourmands who flock to McCaffrey's family-owned chain and its homemade prepared foods. Would McCaffrey, Giant asked, want to snap up Newtown?

The gesture was born not of beneficence, but of regulatory oversight. The Federal Trade Commission was barring Giant from buying the Newtown Genuardi's because it would leave only Giant and Acme selling groceries in side-by-side shopping centers in the rural-turned-suburban outpost — a recipe for potentially higher prices, the FTC worried.

And so, over the last 2 1/2 months, after exchanging piles of Fed Ex-ed and faxed documents between McCaffrey's one and only lawyer and teams of lawyers for Giant and the FTC in Washington, the niche supermarket chain that feels and acts like a smaller, cozier Wegmans is poised to seal a deal that will close early next month, the same day Giant buys its Genuardi's sites and immediately unloads Newtown onto McCaffrey's for an undisclosed price.

On Tuesday, James McCaffrey beamed as he discussed the pending acquisition during an interview at his Yardley store. Customer after customer greeted him on a first-name basis, congratulating him for what is clearly a buzzworthy development in an upscale suburb where households, according to his market research, have incomes of $90,000.

"They have a great bakery," shopper Kathryn Schwenzer, of Lower Makefield Township, said about Genuardi's, stopping McCaffrey near the seafood aisle to make a case for preserving that vestige of the dying chain. "Their bakery is spectacular."

"We've hired their bakery manager," McCaffrey replied. (What he did not explain: McCaffrey's makes all its own prepared foods and baked goods at a 33,000-square-foot central commissary it owns in Langhorne, and conducts blind taste tests on what it makes. Bread recipes, as a result, won't just change on a dime.)

Before approving the deal, the FTC wanted to know tons about McCaffrey's — from detailed financial statements to the exact coordinates by longitude and latitude of the three stores it owns in Yardley, Princeton and West Windsor, N.J., he said.

"We, literally, almost sent them a suitcase full of information," McCaffrey said, sounding grateful for having been brought into the deal at all after what had seemed like failure. "We sent them audited statements, and they came back to us with a ton of questions. They really did their homework."

The FTC's interest in the region's 27 Genuardi's supermarkets, plus a stand-alone pharmacy in North Wales, followed news that corporate owner Safeway was looking to divest the chain.

When family-owned Genuardi's was acquired by Safeway years earlier, it was similar to McCaffrey's: religiously devoted to customer service, organic and fresh food, and a small-store feel. But industry observers and customers said Safeway effectively diluted that appeal as it shoehorned the stores into a corporate culture focused on efficiency in operations.

Not all Genuardi's stores have been sold or shut down, but a majority have been or will be transferred to new operators.

Recently, Safeway closed on a deal to sell three Genuardi's to the Sunbury-based Weis Markets chain, and it has agreed to sell 16 supermarkets and the pharmacy to Giant, a subsidiary of Netherlands-based Ahold. It is from that group that Giant will immediately divest the Newtown site to McCaffrey's.

Safeway also has shut down three stores, intends to close another in August in Cherry Hill, and has not yet resolved the fate of four remaining locations: Audubon in Pennsylvania, and Marlton, Egg Harbor Township and Barnegat in New Jersey, spokeswoman MaryAnne Crager said Tuesday.

The FTC's concern was that Ahold, with 2,970 supermarkets and specialty stores in the United States and Europe, would be too concentrated in the Newtown area through its Giant division. Giant moved aggressively into Bucks County as Genuardi's began to weaken under Safeway ownership.

"The acquisition would reduce the number of supermarket competitors from three to two," the FTC said in its complaint against the proposed deal, "creating a duopoly between Giant and Acme Markets."

Customers associated Giant and Genuardi's as competitors, the FTC noted; plus, without a third player in the region, regulators worried that Acme and Giant — despite being rival chains owned by different companies — might tacitly raise prices at both stores.

Because none of McCaffrey's stores was within six miles of the Newtown Genuardi's, and for related reasons, the FTC considered it to be a "highly suitable purchaser" and "well-positioned to enter the relevant market and prevent the increase in market concentration and likely competitive harm that otherwise would have been caused by the acquisition."

The commission approved the deal, 5-0.

On July 6, McCaffrey's will take ownership of the old Genuardi's, spend several days sprucing it up and restocking it, and open it a week later. A $4 million upgrade will follow in the coming months, McCaffrey said.

Giant has offered jobs to 1,700 former Genuardi's associates, while McCaffrey has hired nearly 100 Genuardi's employees from the Newtown store.

With a planned workforce of 150 in Newtown, McCaffrey's will employ 850 people and immediately boost its $100 million in annual sales.