TAIPEI, Taiwan (AP) _ About 1,000 demonstrators demanding an end to 38 years of martial law fought with stone-throwing members of a pro-government group outside the legislature Friday. Four people were reported injured.

Reporters at the scene estimated at least 3,000 security officers moved to seal off the legislative compound, where the opposition Democratic Progressive Party's demonstration lasted for more than six hours.

The dissidents, mostly native Taiwanese, chanted slogans and shouted support for the party. Some wore green headbands reading ''We don't want the National Security Bill.''

The Legislative Yuan, Taiwan's highest lawmaking body, is considering national security measures proposed by the ruling Nationalist Party as a replacement to martial law, which President Chiang Ching-kuo has said he would lift.

After a verbal exchange, fights broke out between some of the demonstratrors and about 100 members of the Anti-Communist Patriotic Front who were at the compound supporting the security bill. Most of the members of the Patriotic Front are of Chinese mainland origin.

Police said two men, one from each group, suffered minor head injuries when they were hit by poles.

One policeman was hit in the eye and another in the head when they tried to stop the fighting, police said. The two were treated at a hospital and released.

Police in full riot gear formed several human walls to keep the Patriotic Dront demonstrators within the compound as dissident speakers denounced the security measures.

Democratic Progressive Legislator You Ching said the party was especially opposed to the provision that hundreds of dissidents sentenced and imprisoned on charges of sedition over the past 38 years would not have the right of appeal after the end of martial law.

Martial law was imposed in 1949 when the Nationalist government fled to Taiwan after losing a civil war to the Communists on mainland China. The Nationalists still claim to be the legitimate government of all China.

The new security measures are expected to be approved by the Nationalist- dominated legislature this month.

Under the proposed bill, civilians would no longer be tried by military courts and the military would not be permitted to screen applications of travelers entering or leaving Taiwan.

But new parties would have to back the unification of Taiwan and China, even though many of the native Taiwanese who make up 85 percent of the island's population of 19.5 million want an independent Taiwan.