Iran's provisonal government faced an embarrassing and potentially dangerous test of its authority today when the commander of the military police, Gen. Seif Amir Rahimi, refused to accept orders for his dismissal.

The order was given by Defense Minister Gen. Taqi Riahi following discussions with Prime Minister Mehdi Bazargan and was then broadcast over the state radio.

Gen. Rahimi, however, told reporters that he rejected the orders. Asserting that he had been instructed by Iran's unofficial head of state, Ayatollah Ruhollah Khomeini, to remain in office, Rahimi boasted, "I am stronger than Gen. Riahi."

"I have 7,000 well-trained troops at my disposal," he added, apparently cautioning the government that he would put up armed resistance to any move by the government to have him arrested.

No comment has been available from Khomeini or his aides in the holy city of Qom, but his intervention was seen in Tehran as a crucial test of whether he would back the government or whether in the words of one Western military observer, "any cowboy can make the running."

It is unclear what effect the dispute may have on the armed forces at a time of agitation in the military ranks. Strikes have been reported in the army for several days and Air Force technicians are holding sit-ins on at least seven bases in support of demands for recognition of elected representatives.

In recent weeks, Rahimi has emerged as a strick disciplinarian, but his dismissal could increase distrust in military ranks over government attempts to rebuild the armed forces' command structure.

In an effort to settle the current impasse, Raihimi said tonight that he will go to Qom Tuesday. He reported that "people faithful to me are guarding the barracks" there.

The dispute erupted after a bizarre graduation ceremony held for military police at their Tehran headquarters this morning.

Security of the barracks was provided by some 70 black-shirted gunmen carrying submachine guns and rifles. Rahimi described them as his personal bodyguards and as "Fedayeen Khoemeini" or Khomeini warriors.

These guards were taken by Rahimi to Qom last month to provide security for Ayatollah Khomeini, but the Islamic revolutionary guard there did not allow them to take up this role.

Speaking to reporters after the parade, Rahimi accused senior officers of plotting to get rid of him and undermine the revolution.

"These people are the enemies of the imam [Khomeini] because they want to weaken the morale of the revolution by seeking a major confrontation," he charged. "They thought by getting rid of me they could break one of the main pillars of the revolution."

He said that he had prevented a plot to have him arrested by traveling to Qom to see Khomeini, who had told him to round up the unnamed conspirators . . .

There is some skepticism over the role assumed by Rahimi as a defender of the revolution. There is also still considerable uncertainty over the degree of support he has from Khomeimi.

A spokesman at Khomeini's residence in Qom, reached by telephone, confirmed that the Ayatollah wanted Rahimi to stay on. The spokesman said Khomeini informed of the general's situation, had said, "He must not go."

Gen. Rahimi has impeccable credentials for the revolutionary rule here, having been in and out of the shah's prisons in the 1960s. He is also well known for the legal defense he provided for Prime Minister Bazargan and leading moderate clergyman Ayatollah Mahmoud Taleghani when they were put on trial by a military tribunal in 1963.

The general's asssertions today were only the latest in a series of outspoken comments on the state of armed forces which covered issues not always the concern of the military police and which defied instructions from Gen. Riahi that all statements on the armed forces should be made through the government.

"This was the pattern and it was inevitably going to lead to a showdown sooner or later," one Western diplomat said.

There also appear to be differences over the willingness of the defense minister and the chief of staff. Gen. Nasser Farbod, to consider the eventual return to Iran of a limited number of foreign military advisers to provide technical support and training for the armed forces.

Rahimi made clear this morning that he supported the idea of Iranians going overseas for military training but that there was no need for foreign advisers to come to Iran. CAPTION: Picture, Gen. Seif Amir Rahimi, right, meets press at military ceremony shortly before the news of his dismissal. UPI