Housing construction fell for the third consecutive month in May, a 2.7 percent decline that put residential building at its lowest level in 29 months, the government reported yesterday.

The Commerce Department report said new homes and apartments were built at a seasonally adjusted annual rate of 1.62 million units last month, the slowest pace since December 1984.

The May setback followed declines of 3.8 percent in April and 5.9 percent in March.

Analysts blamed the weakness on the sharp runup in mortgage rates in April and May and said the increases were likely to depress construction and sales for the rest of the year.

Fixed-rate mortgages had declined to a nine-year low of 9 percent at the end of March before rising sharply on investor fears over the falling value of the dollar and rising inflation. After hitting a high of 10.81 percent three weeks ago, fixed-rate mortgages now have edged back slightly to 10.66 percent, according to a weekly survey by the Federal Home Loan Mortgage Corp.

Analysts said while they expected mortgage rates to hold steady at current levels, the 1.5 percentage point increase was taking its toll.

"We had to anticipate that the rise in interest rates that occurred from the end of March to late May was going to adversely affect the single-family market, and it certainly has," said Lyle Gramley, chief economist for the Mortgage Bankers Association.

He said the rise in interest rates had forced him to revise his forecast for housing starts down to 1.6 million for all of 1987. While this would be a drop from the 1.8 million units built in 1986, it would still represent a healthy pace for the housing industry, he said.

David Seiders, chief economist of the National Association of Home Builders, said builders clearly were worried about rising mortgage rates and were scaling back building plans.

For the first five months of the year, construction is down 10.5 percent from the same period last year.

James Christian, chief economist for the U.S. League of Savings Institutions, predicted mortgage rates would hold steady for the next few months and begin rising slightly to end the year at around 11 percent.

He said some of the adverse impact from the higher mortgage rates would be lessened by a movement of buyers back to adjustable rate mortgages, which carry lower initial monthly payments.

In May, the weakness came in construction of single-family homes, which fell 7.6 percent to an annual rate of 1.13 million units.

Construction of multifamily dwellings was up 10.8 percent to an annual rate of 491,000 units, but did not regain the ground lost from a big 14.6 percent drop in this sector the month before.

Analysts expect apartment construction to be very weak this year because of the adverse effects of the new tax law, which removed several real estate tax benefits, and because of high vacancy rates around the country.

Building permits, considered a good sign of future activity, dropped 7.6 percent in May to an annual rate of 1.48 million units, the lowest level since March 1983.

The decline in construction activity was concentrated in the South and West. Construction dropped 6.3 percent in Southern states to an annual rate of 630,000 units. Activity was off 6.9 percent in the West, where homes and apartments were built at an annual rate of 380,000 units.

The Northeast, which for more than a year has been the hottest sales area, saw construction activity rise 6.9 percent in May to an annual rate of 294,000 units. Housing starts edged up 1.9 percent in the Midwest to an annual rate of 316,000 units, supporting a belief that this economically depressed region is beginning to show signs of reviving.