Paul Sancya/Associated Press

Kroger is signing up for a bigger dose of fruits and vegetables.

In what may strike shoppers as an odd union, Kroger, the nation’s second-largest retailer, announced on Tuesday that it would buy Harris Teeter, an upscale grocer known for fresh foods and produce, in a deal valued at $2.5 billion.

Harris Teeter’s annual sales in 2012 were only $4.5 billion, or less than 5 percent of Kroger’s. The upscale regional grocer has 212 stores concentrated in the Carolinas and in the Washington, D.C., region that will expand Kroger’s national footprint into areas with growth potential and affluent shoppers.

Kroger hopes to learn from Harris Teeter’s expertise in fresh foods and private-label goods, among other things, according to Kroger’s chief executive, David B. Dillon.

The deal was attractive to Kroger, which is based in Cincinnati, because Harris Teeter’s margins were better than the national chain’s, analysts said. It will not involve changing Harris Teeter’s brands or name, a localized strategy that has been critical to Kroger as it competes against Walmart, its chief rival whose low prices have dented Kroger’s gross margins by several points in the last decade or so.

Grocery made up 55 percent of Walmart’s $275 billion in sales in the United States in 2012. “Kroger absorbed the brunt of the Walmart incursion into the food space frontally long before everyone else,” said Jonathan P. Feeney, an analyst at Janney Capital Markets.

In keeping the Harris Teeter name, its North Carolina headquarters and much of its top management, Kroger is adhering to an approach it has used in other parts of the country. While it operates stores under its own name, Kroger also maintains several regional units, including Ralphs, Dillons, King Soopers, Fred Meyer and Q.F.C.

“What we’re trying to do is not so much a plan of going in and taking over their stores and putting things in place there, which, if I was a customer I actually would be a little afraid of that,” Mr. Dillon said. “In the beginning, I don’t think shoppers will see any difference.”

He said that he believed the best American grocery chains felt local to customers, and keeping the names of places like Harris Teeter or Q.F.C. was important in reinforcing that loyalty. It results in “a much more satisfied customer than if you were to change all the names to Kroger and homogenize the store experience,” he said.

The two companies can also exchange experiences and Harris Teeter might pick up tips on loyalty programs from Kroger, where more than 90 percent of items purchased are bought by loyalty-card members, while Kroger might learn from Harris Teeter’s approach to fresh food, he said.

“They have a stronger fresh reputation, and by fresh I’m really referring to all the perishable departments, than some of the Kroger operations,” Mr. Dillon said. “Our intent is to learn from them, ‘How do they get that reputation? What are some of the things they do that create that?’ It won’t be as much, I think, in the actual products as in the methods by which we get the products to the market.”

Mark Hamstra, retail and financial editor at Supermarket News, agreed that Harris Teeter was more focused on perishable foods than Kroger, a chain that many analysts described as largely known for its reliance on “center-aisle goods” or staples. Harris Teeter, he said, is known for “nicely appointed stores in terms of their merchandising, they do a really good job of making stores comfortable and easy to shop.” And he added, “they really emphasize the quality of their prepared foods, their baked goods, their produce, their meats.”

Analysts said they did not expect Kroger to change Harris Teeter much.

“They are very familiar with exactly this kind of chain,” said Andrew P. Wolf, an analyst at BB&T Capital Markets, pointing to Q.F.C., a relatively upscale chain in the Northwest that Kroger owns. “The historical truth is that if you muck with a brand, you ruin it; they’re smart enough to know not to do that.”

While the upper end of the grocery market is faring better than the low end, and Harris Teeter lends Kroger more of an upscale presence, Mr. Dillon cautioned that the national grocery store chain would not shift overall in that direction.

“I wouldn’t take it to suggest that we’re trying to change the whole company in that direction — we’re just trying to serve that customer better,” he said.

Kroger said it expected the deal to result in savings of $40 million to $50 million over the next three to four years, which analysts said was a minute amount.

“That’s not a very aggressive number. To me, it’s a testament to how much they kind of want to leave things as they are,” said Jonathan Feeney, an analyst at Janney Montgomery Scott.

Mr. Dillon said Kroger had first approached Harris Teeter about a decade ago, but the company was not interested in selling. In February, though, Harris Teeter said it had hired JPMorganChase to explore “strategic alternatives,” investment-speak for a sale.

Kroger said it would finance the transaction with debt and assume Harris Teeter’s outstanding debt of about $100 million. Kroger stock rose 2.65 percent on Tuesday, closing at $37.15. Shares of Harris Teeter rose 1.53 percent to $49.26.

The deal remains subject to approval by regulators.