The maker of Hershey bars has discovered it's hard to resist pressure to raise prices.

Between last fall and this spring, executives at Hershey Foods Inc. unsuccessfully struggled to maintain the price of their candy bars at 25 cents while M&M Mars Co. was charging 30 cents.

Management at No. 2 Hershey believed consumers would shy away from paying 30 cents for Mars' candy bars, which include Three Musketeers, Snickers and M&Ms.

After six months of holding the line, Hershey abandoned its low-price market strategy in March, announcing a price increase to 30 cents and an average increase in the size of its candy bars of 28 percent.

The new Hershey products are now reaching supermarkets and other retailers in the candy distribution chain.

Hershey's move to the 30-cent price marks a victory for recent market strategy by long-time archrival Mars. Hershey apparently went along with 30-cent prices for two major reasons: Its battle plan was frustrated by retailers who decided to charge 30 cents across the board for candy bars, and it was losing market share to Mars anyway, higher prices or no.

This most recent episode in the continuing battle for the allegiance of America's sweet tooth is a year and a half old. It began when Mars, which was losing market share to Hershey, boldly broke with candy industry tradition by increasing candy-bar size without raising prices.

"The move caught the whole industry off guard," says Janet Kitt, who watches the candy business for American Consulting in Chicago. "All of a sudden Mars was out there with bigger bars."

Smelling a bargain, candy buyers turned to the bigger Mars products and the company's market share went from 37.8 percent in July 1980 to 41.1 percent in July 1981.

Hershey lost market share, dropping from 27.3 percent to 26.9 percent. Two other major candy manufacturers also lost share to Mars. Peter Paul, maker of Mounds and Almond Joy, dropped from 7.6 percent to 6.7 percent, and Nabisco Brands, maker of Baby Ruth, Butterfinger and Junior Mints, fell from 8.2 percent to 7.3 percent.

In the $5-billion-a-year candy business, one percentage point of market share represents $50 million in sales.

About nine months ago, Mars upped its prices from 25 cents to 30 cents, a move that should have been to Hershey's advantage. Although it had smaller bars, Hershey also had lower prices and was selling its candy at about the same cost per ounce. Hershey decided to stand and fight at 25 cents.

But Hershey's strategy, backed by pointed advertising, was scuttled by most candy retailers who refused to deal with two prices, going with the higher one.

"The mom-and-pop store doesn't want to bother with, 'Is this bar Hershey's,' or, 'Is this bar Mars,' " Kitt said. "It was very difficult for Hershey to maintain the 25-cent price at retail level."

Continuing drops in cocoa prices helped Mars decide to make bigger bars for the same price. Cocoa powder accounts for about 40 percent of all ingredients used by U.S. candy manufacturers; raw materials make up 48 percent of candy production costs.

Mars is likely to have traded some short-run profits for gains in sales, but as the prices of sugar and cocoa declined substantially over the past 18 months, Mars' gamble probably paid off handsomely.

It's impossible to tell exactly how successful Mars has been, because the Fairfax-based company is privately owned. Sales are estimated at more than $3 billion, of which 40 percent is candy.

Industry analysts believe, however, that it was Mars' private ownership that allowed it to take a long view on profits. "Mars can pursue an aggressive strategy," says Lee Tawes, an analyst with Oppenheimer & Co. in New York. "It can sacrifice profits for a year."

Since Hershey is publicly held, pressure to maintain high profits, even in the short run, is likely to be stronger than at Mars, Tawes notes. "Hershey is at a disadvantage."

Changing bar weight is a common way for manufacturers to vary the price consumers actually pay for candy, besides changing price per bar. Bar prices jump in nickel increments to make life easier for retailers. The accompanying chart on page F1 illustrates how this works.

Since 1969, when candy bars went from a nickel to a dime, Hershey has raised the price of its well-known Hershey bar four times to reach 30 cents. It has changed the bar's weight 13 times.

As the cost of raw materials, energy and labor rose during the 1970s, the price per ounce of the Hershey bar increased from 6.7 cents in 1969 to 20.7 cents today. Other candy bars have had similar progressions.

Despite Hershey's defeat in the latest round of the candy fight, its performance has been enviable. The company earned a 20 percent return on equity last year, compared with a 16.5 percent return for the food industry.

"I give Hershey high marks," Tawes says, praising the company's management. "They have been able to take their basic business and build it and at the same time increase their diversification. In doing so, they have achieved one of the highest levels of profitability in the food industry."

Competition in the candy industry intensified during the 1970s, when cost grew and demand abated. In 1971, Americans consumed an average of 19.3 pounds of candy per person, falling about 15 percent since then to 16.3 pounds per person last year. Candy makers have been able to avoid losing sales as population grew, but the industry is clearly not growing.

To attract more business, candy manufacturers have been quickly adding new products. Hershey has been successful with several new offerings in the past two years, Tawes says, listing Reese's Pieces, Kit Kat, Whatchamacallit, and a new bar called Skor, currently being test marketed, as examples.

Kitt at American Consulting calls Hershey's introduction of a 50-cent "big block" variety of its Hershey, Mr. Goodbar and Special Dark "a brilliant move on their part." She says consumers are responding to the chunky bar because it's thicker, doesn't break as easily and, as she puts it, "You really do know you're eating a candy bar."

To accommodate new products, Hershey is building an $86 million plant in Stuarts Draft, Va.

Industry watchers are unsure what competitive moves to expect in the candy industry next. Mars' unprecedented action in 1980 appeared to change the competitive tone. Kitt says the smaller candy manufacturers, who make up a third of the industry's sales, look to Mars and Hershey to lay the ground rules on pricing.

Hershey's initial reaction to Mars' size and pricing confused a number of smaller firms, Kitt says, leaving "the rest of the industry wondering what to do." Most followed Mars to bigger, 30-cent bars.

Despite the uncertainty, she predicts an end to increases in candy-bar size and weight. She notes that manufacturers are now producing the biggest bars in more than a decade, and "there's a limit to how much you can eat in a candy bar."