NEW YORK (AP) _ An advertising agency lost a longtime job creating ads for a cookie and candy company last week, apparently because it made a commercial for another client's new no-smoking policy that angered the cookiemaker's bosses - who also make cigarettes.

Officials at both the ad agency, Saatchi & Saatchi DFS Inc., and the food and tobacco company, RJR Nabisco Inc., declined repeated requests last week to discuss what led to the blowup, which ended an 18-year relationship.

RJR attributed the dismissal to ''philosophical differences.'' Saatchi said it was ''very saddened and disappointed'' by the decision.

But reports on the situation captivated both advertising executives and those who follow the business for days.

Some said the firing was unwarranted. Others called it an understandable emotional reaction by a company facing growing pressures from groups who want to outlaw some of its profitable products.

''If I was RJR, I would have done the same thing,'' said George Lois, chairman of Lois Pitts Gershon Pon-GGK in New York.

''RJR lives, breathes and exists on cigarettes. Here is an agency that does a commercial that shows planeload of people embarrassing a cigarette smoker. I can see the emotional reaction that RJR had, and I don't think it's an irrational reaction. That's how RJR exists,'' he said.

The commercial at issue was an ad for Northwest Airlines that showed passengers standing to applaud when informed that the airline soon would ban smoking on nearly all its domestic flights.

Others say the agency may have saved itself a lot of trouble if only it had informed the tobacco company in advance of the campaign. RJR Nabisco reportedly was upset partly because it wasn't told about the imminent anti- smoking ads.

One Saatchi executive, insisting on anonymity, said the agency ''should have thought it through more'' and informed RJR about its involvement once the ads started running. But he indicated that because the agency was admaker only for RJR Nabisco's cookie and candy businesses - not its tobacco products - the logic of that approach wasn't apparent at the time.

It is not the first time an agency has upset one client by taking on an assignment in an apparently unrelated area.

Hallmark Cards Inc., for instance, changed ad agencies in 1984 after its old agency won the assignment of making commercials for a long-distance telephone service. The Kansas City-based greeting card maker felt the sentimental approach it took in selling its cards was too similar to that taken by the phone company in selling calls to family and friends.

''We were uncomfortable with a single agency doing both pieces of work,'' said Steven Doyal, a spokesman for Hallmark. ''We were not certain the agency could maintain the level of consistent advertising excellence that both companies would want with the same style of advertising.''

One of the ironies in the RJR-Saatchi case is that the agency did no cigarette advertising for RJR. In fact, Saatchi creates commercials for True cigarettes, which are made by RJR rival Lorillard Inc.

''We don't like that (Northwest) ad at all and we told them so,'' said Sara Ridgway, a spokeswoman for Lorillard. ''But we did not fire them. We didn't think it warranted firing them.''

She said Lorillard has had a good relationship with the agency since hiring it in 1980. The company thought about changing agencies last year and invited several others to compete for the True account but ultimately decided that Saatchi's work ''was the best one for our product.''

Steven A. Greyser, professor of marketing at the Harvard Business School, said that is the way businesses should make decisions.

He said Saatchi's longevity in creating ads for RJR's Life Savers candy for 18 years and its Nabisco cookies for 12 years indicates the agency must have been doing its job.

''I see this as an inherently knee-jerk reaction by some people who don't understand why they hired an advertising agency in the first place - to provide excellent advertising and good service,'' Greyser said.

''It was not a very smart thing to do,'' he said.