Counterrevolutionary guerrillas have stepped up their pressure on the Nicaraguan government with a heavy attack on this provincial capital. They withdrew this morning after 24 hours of fighting that they said marked the start of a new "urban" phase of their struggle.

The combat, which took place mostly in the hills around Ocotal, was the heaviest in northern Nicaragua in a month. Residents reported hearing loud explosions and heavy machine-gun and rifle fire.

The CIA-financed rebels had said in a communique yesterday that their objective was to penetrate Ocotal, but they failed to reach the center of the city.

During a lull in the fighting last night, 200 to 300 guerrillas walked into the northern neighborhood of Barrio Sandino but left after several hours, residents said. They painted slogans on houses and distributed copies of a printed propaganda leaflet.

"We are in this departmental capital to begin a new stage in our insurrectional process: urban guerrilla warfare, as we armed farmers have come down from the mountains," the leaflet said.

The attack was carried out by the Nicaraguan Democratic Force, which is based in Honduras. Ocotal, capital of Nueva Segovia Department, or province, is eight miles south of the Honduran border and about 80 miles north of Managua, the Nicaraguan capital. The town of 25,000 is located on the only good road connecting far northern Nueva Segovia province with the rest of the country.

In Managua, the Foreign Ministry announced that Honduran-backed rebels destroyed a customs office in the town of El Espino on Monday, The Associated Press reported. The ministry said the fighting in the town, involving about 200 rebels backed by Honduran soldiers, continued into the night. No casualty figures were given.

Earlier Monday, the rebel Radio September 15 claimed that attacks were made in Esteli, Nueva Segovia, Jinotega, Madriz and Zelaya provinces. El Espino is in Madriz province.

The Nicaraguan Democratic Force said last month that it intended to begin carrying its fight to the towns after failing last summer to hold a slice of countryside along the Honduran border when its guerrillas came under heavy attack by government troops. The rebels also have begun a campaign of sabotaging vital economic targets.

Observers said the attack here may have been timed to coincide with an address scheduled for Tuesday by Nicaraguan chief of state Daniel Ortega at the U.N. General Assembly.

The attack on Ocotal follows a resurgence of attacks against targets inside Nicaragua by the Nicaraguan Democratic Force and another antigovernment group based in Costa Rica. The Nicaraguan Democratic Force damaged oil loading facilities in Puerto Sandino in an underwater attack earlier this month.

The Costa Rica-based group, the Democratic Revolutionary Alliance, has staged several air raids against Sandinista targets, including the airport at Managua on Sept. 8.

Yesterday's action followed a period of relative inactivity by the Nicaraguan Democratic Force. Adolfo Calero, a leader of the group, told Washington Post correspondent Edward Cody in Miami that while the rebels might not yet be in a position to hold Ocotal, it was important to them to attack a significant target.

The Nicaraguan Democratic Force last made a major attack in August, when about 200 rebels reportedly hit the town of Ciudad Sandino, also in Nueva Segovia province. Sandinista forces repelled them. In May, the antigovernment forces besieged the far northern town of Jalapa for several days.

Residents here said that all was quiet by about 10 a.m. today and that the rebels had left. Soldiers at a barracks on the northern edge of town said the rebels were being pursued by patrols of regular Army soldiers, reservists and police.

Officers were not available at the local military headquarters to provide a casualty count, but at least two Sandinista soldiers reportedly were killed.

Residents also reported fighting near the neighborhoods of Zamora and Antunez.

Rebel forces planted an explosive device at the southern edge of the main bridge over the Coco River linking Ocotal to the rest of Nicaragua. It blew an eight-foot-deep crater that blocked vehicle traffic over the bridge, but the damage appeared easy to repair.

The same bridge was destroyed by anti-Sandinista forces in March, 1982, one of several actions that led to a state of emergency that is still in effect. It had been repaired only recently, a resident of Ocotal said.

Most residents in the town appeared calm late this afternoon and there were few signs of military activity.

The insurgents painted the slogans "Christ Yesterday, Christ Today," and "God, Country, Liberty" on the home of Noemi Rodriguez, 38, in Barrio Sandino. Her neighbor, Antonio Corea, 27, was urged by a column of rebels to join them.

"They asked me to go with them. It made me nervous," Corea said.