Crowds of Pakistani protesters marched on American diplomatic missions today, and the U.S. Embassy warned American citizens to guard against possible attack, amid increasingly angry reactions to the U.S. air raids against Libya.

In Lahore, 165 miles southeast of here, four separate groups demonstrated at the State Department-run American Cultural Center, which closed for the day on the advice of local police. In one demonstration, by about 3,000 Shiite Moslem and leftist students, protesters waved pictures of Libyan leader Muammar Qaddafi and Iran's Ayatollah Ruhollah Khomeini, threw burning effigies into the center's courtyard and pelted the building with stones, witnesses said.

"If America does not apologize to Libya, the American Center will be burned," one speaker declared as the crowd chanted, "Burn, burn." About a hundred Shiite students then marched to the offices of American Express and rushed in to smash windows, office equipment and furniture while employes fled into the street.

In the southern city of Karachi, police used their vans to block streets leading to the American Consulate, thus turning back demonstrations by leftists and the fundamentalist Jamiaat-i-Islami party. One group of protesters shouted for Pakistan to send its troops and American-built F16 jet fighters to "fight American terrorism" in Libya, local journalists reported.

A U.S. Embassy staffer said the embassy had warned its personnel of its "continued expectation of anti-American demonstrations, especially Friday," with a rally planned in neighboring Rawalpindi for the Pakistani opposition leader Benazir Bhutto. Americans were advised not to travel outside the capital or shop in local markets and bazaars.

The protests underlined an apparent recent increase in anti-American sentiment in Pakistan, an important strategic ally upon which the United States lavishes economic and military aid. Fundamentalist Moslems oppose the United States over its policies toward the Middle East and Iran; Islamic militants attacked and burned the American Embassy here in 1979.

Other Pakistanis, including leftists and many supporters of opposition leader Bhutto, oppose the United States for supporting President Mohammed Zia ul-Haq, whom they regard as a dictator. The Reagan administration recently agreed with Zia's government to provide more than $4 billion in aid, nearly half of it military, over six years.

The embassy and other U.S. facilities here reflect the ongoing problem of anti-Americanism in Pakistan. The embassy, set in a large compound behind brick walls and antivehicle ditches, is well defended. Outside its front gate, a 30-yard zone is being cordoned with stone pillars meant as an additional barrier to suicide truck bombers.

The problems have increased in recent weeks. In mid-March, U.S. Navy ships, including the aircraft carrier USS Enterprise, caused anti-U.S. demonstrations in Karachi when they stopped to allow sailors shore leave in the city.

After Tuesday's air strikes against the Libyan capital, U.S. and Pakistani authorities increased security around all U.S. facilities in the country, including the American-run primary and secondary school in Islamabad. Embassy officials also said they had taken the unusual step of holding a special meeting to explain to Pakistani staffers, including maintenance, security and dining room personnel, why the administration had ordered the air raids.