Up to a million Iranians poured into the streets today to support Ayatollah Ruhollah Khomeini's demand for the ouster of Prime Minister Shahpour Bakhtiar. But the embattled prime minister vowed never to surrender "in an atmospher of chaos, grenades and molotov cocktails."

Bakhtiar, under increasing pressure to give in to Khomeini's Islamic-inspired movement and its provisional revolutionary government, said he could accept a referendum organized by the religious opposition only if it is held in "an atmosphere of democracy."

Referring to Reza Shah, the founder of the Pahlavi dynasty, and his son, the now absent Shah Mohammad Reaza Pahlavi, Bakhtiar said at a news conference: "I never surrendered to Reza Shah or Mohammad Reza, and I will not surrender to Bazargan or Khomeini.

Mehdi Bazargan was named by Khomeini on Monday as prime minister of his provisional government.

As Bakhtiar spoke, the vanguard of a massive demonstration called to the streets by Khomeini began assembling for a two-mile long march through Tehran's main streets to Shahyad, the futuristic royal arch that is now covered with revolutionary graffiti.

From start to finish, it was a peaceful demonstration under dark winter skies, mixed with sorrow for fallen martyrs and jubiliation for a struggle that seems to be nearing a victorious conclusion.

A few pro-Khomeini soldiers in uniform participated, but not nearly in the numbers predicted by parade organizers.

Enormous portraits of Khomeini and banners declaring, "We support Bazargan with our blood," snapped in the breeze. Marchers sang revolutionary songs and shook their fists at an occasional Iranian Army helicopter flying low overhead.

But except for cursory surveillance and a few soldiers standing guard outside government buildings, the military remained as inconspicuous as it did when a similar march was held on Khomeini's return a week ago after 14 years in exile.

Although there were unofficial estimates of one million to two million marchers, the size of the crowd defied accurate reckoning. It appeared as large as gatherings held on Ashura, the Shite Moslem holy day, in December that started the final push leading to the shah's ouster.

Khomeini has called for similar demonstrations throughout Iran until Bakhtiar resigns and an Islamic republic is installed. However, Bakhtiar seemed at his news conference to be far from resigning. He more than once chalenged Khomeini's right to demand control over 35 million Iranians.

Saying he was ready to discuss Iran's problems with Khomeini, Bakhtiar declared: "But one mullah is not a government. I'ts not the job of one mullah to direct a government."

Bakhtiar said he was "disposed to change the constitution, but constitutionally," and he called on the opposition to form political parties and achieve power legally.

The prime minister sidestepped questions about whether he personally would go along with a move to abolish the monarchy. But he suggested that he could call for elections before the required six months after taking office.

"If everything is quiet, I can call for elections before that. But if it's noisy in the streets, it's not possible," Bakhtiar said.

When asked if he has the support of the U.S. government, Bakhtiar replied: "I don't know. Ask President Carter... If the American government gives its assistance, so much the better. If it doesn't give it, too bad."

U.S. officials here have said that as long as Khomeini does not provoke the army, a victory by the religious opposition is inevitable, and they have stepped up their contacts with Khomeini's advisers.

Wire service reported :

Nine persons were reported killed and 26 others wounded when troops opened fire on anti-Bakhtiar protesters setting fire to banks, shops and other buildings in Gorgan on the Caspian sea, the state radio said.

Opposition spokesmen said a group of Moslem mullahs, or preachers, were attacked and beaten while they were on the way to an opposition rally at the town of Koi, near the Turkish border.

Turkish radio reported that the main Iranian Turkish border crossing, near the Turkish village of Gurbulak, was opened to trucks today after more than a month of closure to heavy traffic. Hundreds of trucks, mostly from Western Europe, had been stranded at the border because of a strike by Iranian customs officials supporting Khomeini.