Nicaraguan government forces retook this customs post on the border with Honduras this morning after two days of fighting anti-Sandinista guerrillas.

Nicaraguan officers and soldiers charged that Honduran troops had supported the guerrillas by firing mortars from a hill across the border onto this hamlet on the Pan American Highway Sunday and yesterday.

"You can see the difference because the Hondurans wear green and the contras counterrevolutionaries wear blue," said Lt. Pedro Rizzo of the Army Border Guard. He also said that his enemies had a type of mortar possessed by the Hondurans but not the rebels.

The attack here by CIA-financed guerrillas of the Nicaraguan Democratic Force was part of their biggest offensive in northern Nicaragua in a month. They also fought Sunday and yesterday on the outskirts of the large town of Ocotal, 20 miles northeast of here.

Fighting had ended here by this afternoon, and officers said the rebels had fled back to Honduras after a counteroffensive yesterday. It was unclear whether the guerrillas had ended their push or were regrouping for further attacks.

The border post, which consists of a dozen one-story buildings and a large customs warehouse, was nearly deserted this afternoon when a group of foreign journalists visited. The only sign that the government had reestablished control was a two-man guard posted on a low bluff on the edge of the hamlet.

On the Honduran side, the customs office was not occupied and the only sign of life visible from here was a green-uniformed soldier on a hill about half a mile away.

Three buildings--a private home, the office of the customs personnel and a building that housed an emergency electrical generator--were gutted; the rubble inside was still smoldering. The structures' roofs were heavily damaged or destroyed.

Six other buildings had been looted or set afire, and slogans of the Nicaraguan Democratic Force had been painted on walls. A file cabinet from the customs office was smoldering after having been dragged into the middle of the street and set afire.

The border post is nestled at the foot of a steep hill on the Honduran side, where the Nicaraguans said the mortars had been placed. Soldiers here reported that three of their comrades had been killed in the fighting, and a Red Cross official said five had been taken to a hospital.

Morale was high among the assortment of government forces, which included middle-aged regular Army soldiers in camouflaged uniforms and teen-aged girls from the militia wearing blue jeans.

"We are an army of the people, and we have more to fight for than the contras," said Army reservist Ramon Duarte, 43, in a comment that was typical of those made by government troops.

In Somoto, the capital of Madriz province in which El Espino is located, citizens walked in the streets with no apparent concern over the recent fighting 12 miles to the west.

"Some people are scared for their children, but I'm not too worried. It's still a ways away, and I don't think they the rebels are really trying to invade," said Julio Valleja, a Somoto restaurant owner.

El Espino first came under mortar attack at 4:30 a.m. Sunday, according to officers and soldiers. The authorities evacuated 840 civilians from El Espino and nearby villages to Somoto.

Government forces insisted that they did not fire into Honduras but only shot at groups of rebels after they had crossed the border.

"We are a peace-loving people and we were told it was important not to start a war with Honduras," said a young militiaman, who would only identify himself as Yassir.

The bombardments ended before noon Sunday, but the rebels shouted from the hills at about 6 p.m. that they were going to resume mortar fire. Government then forces pulled out of the customs post and the guerrillas moved in during the night. Governmental and rebel forces skirmished in the heavily wooded hills along the border, and at one point a rebel band penetrated deep enough to attack a bridge 2 1/2 miles from the border on the Pan American Highway.

Troops said the rebels had 300 soldiers, compared with about 40 that the government had at the border, so reinforcements were called in. Government patrols swept through the woods yesterday, battling guerrillas on the highway just outside the hamlet. Officers said the guerrillas withdrew before dawn today.

In other fighting in the north, government forces yesterday beat back a five-hour assault on the isolated village of Santa Maria three miles from Honduras, a militia officer in Ocotal said.

The officer, Fernando Aguirre, said that two government planes had flown missions in the area but he denied an accusation by the Nicaraguan Democratic Force that planes had bombed Santa Maria.

Militiamen near Santa Maria said they had seen vehicles carrying two dead persons and three wounded out of the village. Journalists were unable to reach Santa Maria today.