El Salvador's ruling junta today bowed to demands of a leftist group for the release from prison of seven of its members in exchange for the freedom of six hostages held at the Panamanian Embassy here since Friday.

A government spokesman said the seven were freed from Usulutan Prison, about 70 miles east of San Salvador. This smallest of Central American countries, crowded with 4.8 million inhabitants, has been in turmoil since last year's revolution in nearby Nicaragua. The six hostages, who were also freed, include two diplomats each from Panama and Costa Rica and two Salvadoran employes of the embassy.

About 50 members of the political action group calling itself the Feb. 28 Popular League stormed the embassy on Friday to demand the release of their seven comrades arrested by security forces last month.

Meanwhile, police said armed leftists today fired on the Guatamalan Embassy in San Salvador. The attackers, members of a group called the Revolutionary Party of Central American workers, damaged the building but caused no injuries.

Earlier today, about 20 unarmed members of another leftist organization, the Popular Revolutionary Bloc, occupied the Roman Catholic Cathedral of San Salvador, chanting antigovernment slogans. Archbishop Arnulfo Romero told reporters earlier that a civil war or general insurrection was imminent in El Salvador.