NEW YORK, JULY 14 -- International Business Machines Corp.'s profit fell 9.8 percent in the latest quarter, the fifth consecutive quarterly decline, but analysts said today they believe the computer giant's period of declining profits has ended.

IBM's quarterly profits should exceed their year-earlier levels through the rest of this year and 1988 as customers snap up its new personal computers and mainframes, several analysts said.

"This was a good number for IBM and I think it indicates the company is on track," said Donald Haback, a vice president of mergers and acquisitions at Nikko Securities International Co.

"I think '88 is a breakout year for IBM," the world's largest computer company, agreed Frank Halpern, an analyst for Martin Simpson & Co.

IBM said it earned $1.18 billion ($1.95 a share), down from $1.31 billion ($2.12) a year earlier. Revenue rose 4.3 percent to $12.8 billion from $12.3 billion a year earlier.

For the first six months of its fiscal year, IBM's earnings fell 15.5 percent to $1.96 billion ($3.25), from $2.32 billion ($3.77) a year earlier. Revenue rose 4.8 percent to $23.5 billion from $22.4 billion a year earlier.

IBM's stock retreated slightly on the news. Although the profit exceeded the $1.85-per-share consensus of analysts, it failed to satisfy investors who had bid up the stock Monday in a surge of overoptimism.

IBM -- which reached new levels in the previous session -- closed down $2.37 1/2 at $167.50. IBM has been struggling with aggressive competition from all sides, especially in personal computers and midsize computers. But it is beginning to benefit from an industrywide upturn in demand as well as cost-cutting measures.

"IBM's shipments and revenues in the second quarter of 1987 continued to show improvement over 1986 levels, and the response to our recent product announcements has been positive," John Akers, IBM's chairman and chief executive, said in a statement.

Demand for IBM's new line of personal computers, the Personal System-2, has been "very strong," Akers said. Some mainframe computer models, including the midsize 9370s and the large 3090E series, are being shipped earlier than planned, he said.

IBM officials indicated to analysts that worldwide orders were slightly up in June compared to a year earlier, after having been down through all of early 1987, Halpern said.

About 13,000 U.S. employes took advantage of an early-retirement incentive that expired on June 30, IBM said.

IBM's results fell far short of the big profit gains reported Monday by Apple Computer Inc., NCR Corp. and semiconductor makers Intel Corp. and Advanced Micro Devices Inc.

But analysts are turning more upbeat on the company. Halpern predicted IBM's earnings would hit $9 a share in 1987 and then jump to about $11.50 a share next year.