A force of about 100 Nicaraguan rebels assaulting this northern town ambushed a military convoy escorting 12 foreign journalists out of the town yesterday, killing five government soldiers and wounding six others.

The correspondents, four of us Americans, lay in ditches and on the surface of the dirt road about five miles outside Jalapa for an hour and 15 minutes as the U.S.-backed guerrillas poured a rain of mortar shells and what appeared to be fire from 50-caliber and M60 machine guns along the highway.

Two of the dead soldiers were part of our 30-man escort, and three others were in an armored truck slightly ahead of our seven-jeep caravan. There were dead or wounded in all four vehicles ahead of us, and in one of the two vehicles behind us.

The wounded included Nicaragua's Defense Ministry spokesman, Capt. Roberto Sanchez, who was escorting the journalists on a government-sponsored tour of the combat zone near the Honduras border.

The rebels, operating out of Honduras, began their heavy offensive against Jalapa on Saturday, reportedly with the intention of seizing a part of Nicaraguan territory and setting up an operation base there. Jalapa has been the scene of intermittent but heavy fighting since December, according to local residents. A major assault in March was aimed at taking the city, guarded by Sandinista reservists, several hundred of whom have been sent here while the regular army has been held in reserve in major cities.

The rebels, described recently by President Reagan as "freedom fighters" and known to be receiving material U.S. support under a covert action program approved by the president, came back to Jalapa on Saturday morning.

They launched offensives from four points around Jalapa, Capt. Ramon Gonzalez, who heads the local Sandinista forces, said.

According to Lisa Fitzgerald, an American nun working in Jalapa, there have been 25 assassinations of local leaders here by the contras, or counterrevolutionaries, during the last 15 months, two of them Nicaraguan Catholic lay workers and 10 of them in a single meeting called to discuss local civil defense.

I arrived in Jalapa, a major coffee and tobacco growing center with a population of 10,000, yesterday to investigate the fighting and to speak with local residents. Three other Americans, working for Time magazine, came to see an unannounced appearance in the combat zone near the Honduran border by the three members of the ruling junta from Managua.

The three, Sandinista guerrilla commander Daniel Ortega, Sergio Ramirez and Rafael Cordoba Rivas, arrived by helicopter in late morning on a grass airstrip outside of town where several hundred Sandinista soldiers are stationed in old tobacco barns.

After speaking to the soldiers, the three and their escorts walked up and down the town's rutted dirt streets, through the main square where a monument declares the park a "gift of the Lions' Club." Stopping people along the way, they asked about last year's floods, this year's drought and the security situation.

They visited six soldiers, one of them 15 years old, in a small local hospital. The soldiers had been wounded in battles Saturday and early yesterday.

The junta flew out of town by helicopter at about 1:30 p.m. We four Americans and eight European journalists were taken to another military camp for a briefing. In the hills to the east, about a mile and a half away, at a place called El Carbon, a loud fire fight was going on.

Then we split into two groups. We Americans and two Swedes went to another airstrip about five miles south of Jalapa where a small plane was to fly us to Managua. A Spanish television team, a French and a Bulgarian photographer went off to where the fighting was. About a mile outside of town, a soldier in a jeep told us there was trouble ahead and to turn back. We did, but had gone only a couple of thousand feet when we came across the other journalists, this time, with an armed escort of about 30 troops in a few jeeps.

Later, several of the European journalists said they heard Sanchez say "Let's go, we've got enough troops here to break through the ambush." But those from Time and I, in another Land Rover, did not hear it. Nor did we know what was happening when our vehicle swung around and began to follow the others back in the direction we had been warned to head away from.

When the first shots came, a little before 3 p.m., we were in a long flat valley and completely exposed. For about half a mile on either side of the dirt road were plowed but empty fields, rising up into high hills.

We had been headed south, to the airstrip at an old coffee farm called La Mia. To the west, just up the road, was a row of low barns, in which contra snipers had hidden. That was where the first blast of fire apparently came from, but a much larger force that we could not see quickly opened up from the other side of the road.

In front of us, inside an armored vehicle that had been several minutes ahead of us, three soldiers aready lay dead. We four hit the floor in the back of the Land Rover, wrapped tightly together. Our driver had jumped out of the vehicle, pistol in hand, and in the front seat another Nicaraguan press official was whimpering on the floor.

While the Sandinista soldiers up and down the line of vehicles returned deafening rounds of fire we debated staying in the Land Rover or rolling out the back door onto the ground. A hail of mortar rounds started falling in front of and behind our vehicle, the concussion blowing us against each other. As one hit about 100 feet behind us, Time magazine chief of correspondents, Richard Duncan yelled to jump out and we rolled into the dirt crawling under the vehicle and along the side of the road.

All we could see up and down the straight road were our own vehicles, some with windows shattered, stopped at odd angles.

As one soldier lying next to me with his face in the dirt behind a tire explained, the contras have two types of ambush. One is to take a single point in the road, which vehicles can sometimes run through with minimum damage.

The other is a much more sophisticated operation designed to hit a convoy such as ours, where a substantial force is positioned to definitely stop the first vehicle. When those behind it put on their brakes to try to turn around, other forces positioned along their flanks and behind the last vehicle open up. We clearly were victims of the second type.

We guessed that the contra force had heard there were important vistors in Jalapa and guessed we might be that group. This being the second type of ambush, the soldiers said, "the idea is to eliminate all of us."

As time passed, it became clear we were completely surrounded. Our only shelter was the vehicle, an easy target and filled with gasoline.

Sanchez, who was wounded behind us, and the three or four soldiers, all of them in their early 20s or younger, lying in our immediate vicinity, appeared calm, polite and clearly concerned about our welfare.

No one asked, as a few angry Nicaraguans did later, how we Americans felt being shot at with guns our government had provided to the contras.

At one point the soldier lying next to me asked me to move my leg so he could point the barrel of his automatic rifle past it. "What are we going to do," I whispered. He answered, "Don't worry. Be calm. We are going to wait because that's all we can do. We've got to bring in our own mortars and drive them back. I'm not going to shoot until they get closer to us. I don't want to draw their fire."

We lay there in the broiling sun under fire for about an hour and a quarter until other government troop fanning through the hills pushed back the contra forces.

A Sandinista spokesman said in Managua later that the government forces had killed 11 guerrillas during the ambush, United Press International reported.

Back in Jalapa, we realized we could not leave because the town was virtually surrounded.

As we stood outside the hospital and bodies were unloaded from the bloody vehicles, one Nicaraguan reporter from Managua who had been with us turned to Duncan and said coldly, "You did this," apparently referring to U.S. support of the contras.

One young soldier who had lost his leg lay screaming for a few moments on the sidewalk, "Mama, Mama, Mama," before they carried him inside.

Later Sanchez, his wounded arm in a sling, brought us several items left behind by the retreating contras--two mortar rounds marked "U.S.A.", two standard issue U.S. military ponchos, a can of U.S.-issue gun oil and a U.S. military first aid kit.

The Sandinistas seemed greatly relieved that none of us had been killed or wounded. At the same time the more politically sophisticated among them appeared aware that the incident could perhaps work to their advantage by appearing in the foreign media.

Sanchez pointed out again and again to us, "Our soldiers didn't run. They knew their duty was to protect you." But the other soldiers, those whom we approached to thank, just smiled and looked embarrassed.

The sounds of combat still rang through the nearby hills as it got dark. Civil defense organizers went through Jalapa with loud speakers calling people to help at communal kitchens for soldiers, to take up their civilian defense perimeter positions, and, in a separate announcement, to meet in the church to pray for the dead soldiers.

At midday today, the Sandinistas flew us and a number of wounded to the northwestern town of Somoto in a single-engine Atonov II Russian biplane, and this evening drove us by bus to Managua.