About 24,000 telephones at Montgomery County residences and businesses were knocked out of service yesterday by a mechanical problem, prompting a flurry of angry calls -- presumably from pay phones.

Phone service to the affected customers in Gaithersburg and Poolesville was cut off at 2 a.m. and was gradually restored over a 12-hour period, according to Don Heath, a Chesapeake and Potomac Telephone Co. spokesman.

Heath said about half of the phones, those with 869, 926, 948, 990, 349, 428 and 972 exchanges, were back on line by about 10:30 a.m. Almost all the affected lines were back in service by 2 p.m., he said.

Technicians attributed the unusual problem to a combination of software and hardware glitches in the phone company's central office in Gaithersburg, Heath said.

Heath said C&P asked television and radio stations to spread the word so that residents would not panic if they tried to seek help on the 911 emergency number.

"We suggested that folks go to neighbors' houses or to pay phones," Heath said.

While the phones were down, the county increased its police presence. "They've beefed up patrols. That's all they can do," said county officer Charles Burkey. "Hopefully we might get lucky and see" an emergency.

Police and fire officials said no problems were aggravated by the phone difficulties.

But some residents were irritated. Once they realized their phones weren't working, they got to phones that were. One C&P employe said she received 68 calls from customers in three hours. Their anger quickly subsided, she said.

Said the employe: "As long as they weren't the only ones who didn't have service, they said they understood."