Nicaragua was invaded along the Costa Rican border by Sandinista guerrillas early this morning for the second time in recent weeks, signaling an escalation in the country's civil war.

A similar attack late last month was routed by the National Guard after a two-week battle in southern Nicaragua, and the government was throught to have that section of the country under control.

At a press conference today, Foreign Minister Julio Quintana said the second attack could have "gave consequences." Quintana said he could be prepared to fly immediately to Washington for an emergency meeting with foreign ministers of the 25 member nations of the Organization of American States.

The attack by a 300-man guerrilla force came on a day when fighting here in the capital raged, with heavy gunfire erupting around the U.S. Embassy, sending armed, flak-jacketed Marines into firing position on the embassy grounds.

The shooting began shortly after 2 p.m., when a group of people that the Marines and six National Guard soldiers inside the compound took to be Sandinista guerrillas was seen crossing a field between the embassy and the empty U.S. ambassador's residence.

For almost an hour, while a few staff persons huddled inside the almost empty embassy building, Nicaraguan troops immediately outside a high fence surrounding the mission field deafening .50-caliber machine-gun rounds, mortars and automatic rifles through the tall grass. There was little return fire.

Government troops reported numerous guerrilla and possibly civilian casualties in the field surrounding the embassy fence. There was no indication that the Sandinists intended to attack the embassy, and no one inside was injured. Marines in the 11-man contingent said they did not fire their weapons.

Meanwhile, in Washington, a State Department spokesman said United States was embargoing all arms shipments to either side in the Nicaraguan conflict, and urged other nations to follow suit.

"The situation in Nicaragua is one of increasing danger and violence and we hope it could be solved by diplomacy rather than the use of arms," spokesman Tom Reston said.

Foreign Minister Quintana had few details of the renewed fighting near the border.

He said the government first had word of an impending attack late yesterday afternoon, when it learned that a "military convoy of heavy vehicles and weapons" had gathered in the small Costa Rican border town of La Cruz.

Radio Sandino, the clandestine guerrilla station, said the Sandinistas had "annihilated" a National Guard border outpost at Penas Blacas.

The Sandinistas were believed to be moving toward the provincial capital of Rivas, where guerrillas had begun a fierce offensive yesterday despite government air strikes.

The Sandinistas' strategy, since they first launched an all-out civil war here last September, has been to attempt to control a substantial area of "liberated" Nicaraguan territory contiguous with a border and preferably in the south. Their aim has been the recognition by sympathetic governments of a provisional government in that territory.

The National Guard won the last round in the south last week at the expense of heavy troop commitments and diminished defense in other portionso f the country. Many of the government's southern troops are believed now to have been brought to Managua, where heavy fighting began last weekend.

Fighting continued today in virtually all of Managuahs slums, with National Guard rocket attacks attempting to dislodge guerrilla positions.

A Colombian Air Force trasnsport plane, atempting to land at the Managua airport to evacuate Colombian citizens, was hit by automatic weapons fire. Witnesses said the plane landed safely but could not take off again, and a crewman was injured. It could not be immediately determined where the gunfire came from.

Nicaraguan Red Cross general director Miguel Schiebel said today that ambulances have been unable to enter combat zones in the city since Sunday. Although the government has announced what it calls "cleanup operations" throughout the city, the guerrillas and their supporters in the slums have managed to reconstruct barricades and firing positions, usually within hours of when the National Guard blows them up.

Schiebel said government officials have contacted the Red Cross about an emgency food distribution program President Anastasio Somoza announced last week, but that he had not yet received any of the food.

"There is enough food for everyone in the country," he said in warehouses and storage silos in various cities, "but we can't get to it." Roads leading to principal agricultural areas in the north have long been blocked by heavy githting.

The Agency for International Development said in Washington that U.S. food supplies will be made available to Nicaragua through the American Red Cross

In addition to a fourth U.S. Air Force evacuation flight of American citizens today, Guatemala, Peru, Argentina, Columbia, Italy, West Germany and Brazil are also in the process of evacuating their employes and citizens from Nicaragua.

While the American flights have left from President Anastasio Somoza's private air strip at Montelimar, 40 miles away, the other embassies have begun to take their people out through private flights into Managua's international airport.

The main airport access road from the city remained blocked by gunfire and rocketing, but the airport can be reached by a way of a 40-mile circle highway to the south of Managua. CAPTION: Picture, Refugees from Managua's embattled slums flee the city with their belongings piled into a cart. The woman at right carries the white flag of a moncombatant. AP