Iraqi security forces in trucks and Humvees barreled into a camp of Iranian dissidents early Friday, and U.S. officials squarely blamed the Iraqi government for the deaths that resulted, saying “the crisis and loss of life was initiated by the Government of Iraq and the Iraqi military.”

Two widely divergent versions of events were offered. Iraqi officials said no more than three people were killed after residents hurled stones at soldiers. A camp spokesman said 31 people were killed in an unprovoked “bloodbath” that involved soldiers opening fire and crushing people under Humvees. Journalists were not allowed near the camp Friday.

The sprawling settlement near the Iranian border, called Camp Ashraf, is home to 3,000 Iranians who are part of Mujaheddin-e-Khalq, or MEK, a media-savvy group with spokesmen in Paris and lawyers in Washington, and which was behind a rash of bombings in Iran in the 1980s. In 2001, the group renounced violence, though it is still designated a terrorist organization by the U.S. government.

The United States has urged the Iraqi government to protect the group’s members, while the Iranian government would like Iraq to expel them. The way the Iraqi government treats the dissidents is considered a gauge of the relative influence the two countries wield over the Iraqi government led by Prime Minister Nouri al-Maliki.

The attack coincided with a visit by U.S. Defense Secretary Robert M. Gates, and it echoed a similar raid during another visit by Gates two years ago. Traveling in the northern city of Mosul on Friday, Gates said U.S. officials were monitoring reports of the clash from “nearby” and were “very concerned with reports of deaths.”

In a statement, Mark Toner, the State Department spokesman, said the United States was “deeply troubled’’ by the clash. His statement blamed the Iraqi government and military for the episode, though he conceded that U.S. officials “do not know exactly what transpired.’’

“We reiterate our call for the Iraqi government to live up to its commitments to treat the residents of Ashraf humanely and in accordance with Iraqi law and their international obligations,’’ he said.

An Iraqi government spokesman, Ali al-Dabbagh, said the residents were not being expelled, but added that Iraqi law does not permit the government to shelter foreign terrorist groups.

The details of the raid were disputed. According to a camp spokesman, Shahriar Kia, Iraqi forces had been building up around Ashraf for days. He said camp leaders had pleaded with U.S. officials to help prevent what they cast as an impending attack.

Early Friday morning, Kia said, Iraqi bulldozers, trucks and Humvees crashed into the northern wall surrounding the camp and began firing on residents and running over others, who tried to defend themselves by throwing rocks.

Within hours, Shahnin Gobadi, a Paris-based spokesman for the group, released the names of six of the residents he said were killed, along with studio-quality photos of them in suits and ties. He said many women had also died, and blamed the United States for not acting to stop the violence.

“The U.S. could have prevented this massacre,” Gobadi said. “We gave all sorts of warnings.”

Dabbagh, the government spokesman, gave a different account of events. He said that Iraqi soldiers arrived at the camp as part of a normal rotation of security forces, and that residents had overreacted by throwing stones at them and moving beyond the fence securing the camp.

“We enforced the law and returned them back inside the camp,” Dabbagh said. The spokesman said he did not know whether any camp residents were killed, but an Iraqi security official, who did not want to be named because he is not allowed to speak to the media, said three camp residents were killed.

Critics have described MEK as a cultish group. In the 1980s, Iraqi dictator Sadaam Hussein let the group’s members set up military bases in Iraq to help him fight his war with Iran. Ashraf was the last of these, and residents agreed to disarm after the 2003 U.S. invasion. U.S. forces had protected the camp until Iraqi forces took over two years ago.

Last year, MEK sued the State Department to have their terrorist designation removed, a push supported by several U.S. congressmen. The U.S. appeals court sent the matter back to the State Department for further review, but left the designation in place.

Staff correspondent Craig Timberg contributed to this report.