In a predawn move marked by unusually tight security, Shah Mohammad Reza Pahlavi yesterday left the New York hospital where he has been undergoing treatment for six weeks and was flown to an Air Force base hospital near San Antonio, Tex.

The movement of the deposed shah or Iran out of the New York Hospital-Cornell Medical Center was carried out under White House supervision yesterday in much the same fashion as he arrived there 42 days ago -- quickly, quietly and under the cover of darkness.

The shah was admitted to the 1,000-bed Willford Hall Medical Center at Lackland Air Force Base after a 3 1/2-hour flight aboard an Air Force DC 9. Air Force officials closed the normally unrestricted base to reporters and other unauthorized outsiders after the shah's arrival.

Richard Armao, a spokesman for the shah, said after the move that it would be "hard to say" how long the 60-year-old Iranian would remain at the Texas base.

President Carter, returning to the White House yesterday from Camp David, said the shah needed to recuperate after undergoing six weeks of treatment in New York for cancer and gallstones.

Carter was asked if the United States would offer the shah permanent asylum. "I can't answer that now," he told reporters.

Carter press spokesman Jody Powell said, "The United States government has agreed for humanitarian reasons to provide a secure convalescent facility where he can recuperate pending further travel plans."

Powell said the United States is still looking for some permanent place for the shah to live; last week the Mexican government rejected his plans to return there.

Egyptian President Anwar Sadat last week offered to let the deposed shah go to his country.

A senior Egyptian official said yesterday that the offer to the shah stands. But Mansour Hassan, Egypt's acting information minister, said in Cairo yesterday that he believed the shah would remain in the United States for several more weeks.

"Personally, because of his health, I don't expect the shah to come to Egypt for some time," Hassan said.

The Associated Press reported that a security official at the Egyptian presidency yesterday said the shah would go to the Bahamas next.

According to Powell, the Texas military hospital was chosen for the shah by Defense Secretary Harold Brown for security and medical reasons.

The transfer of the ailing shah from the New York hospital where he has been since Oct. 22 began just after 4 a.m. yesterday.

Dr. Benjamin Kean, who originally admitted the shah to the hospital after flying to examine him at his retreat at Cuernavaca, Mexico, signed him out.

Kean refused to make any comment to reporters at the hospital yesterday about the shah's condition. The former Iranian monarch has been treated for cancer of the lymphatic system and has had his gall bladder and several gallstones removed at the hospital.

While reporters waited outside the hospital, the shah was taken from his 17th-floor room to the basement. A hospital spokesman said the shah was ambulatory during the move.

The shah was taken through a tunnel from the hospital to a green van waiting in a garage across the street. The van was escorted without emergency lights or sirens in a five-car motorcade to LaGuardia Airport in Queens.

According to authorities, the shah's motorcade was organized and controlled by the FBI. New York police were not involved and were given almost no warning of the move.

One newspaper photographer, who chased the motorcade in his own automobile, said that when he drew near the shah's party an unidentified man leaned out of a car going about 40 miles an hour, waved a shotgun in his direction, and yelled "Back off or we're going to shoot."

At the airport the motorcade drove alongside the Air Force DC9 and the shah, the Empress Farah and several others went on board.

According to police who saw him leave, the shah appeared reasonably strong and healthy and walked unassisted up the stairway into the airplane. He spoke to no one and made no wave or gesture.

Police of the Port Authority of New York-New Jersey, who have charge of airport security and operations, were given several hours' notice of the shah's departure, officials said.

State Department officials here said the shah would be billed later for the cost of the flight and for all his medical expenses at the military base in Texas.

The Lackland base has been used for the last 25 years as a training base for thousands of Iranian military personnel. The flow of Iranians was abruptly closed off last January after the shah was deposed. A base spokesman said yesterday that military students from 30 countries are still at the Lackland training facility.

Texas officials generally welcomed the shah. Sen. John G. Tower (R-Tex.) called him "an old ally of our country." But San Antonio city council member Bernardo Eureste warned that "we are possibly going to have some rough days ahead." City officials said they were not told of the shah's arrival or given any warning.

Military officials in Texas said that the usual security at the Lackland hospital is light. But after the shah's arrival, extra guards were put on duty checking identification of persons entering the base and recording car license plate numbers.

Guards at the hospital's main entrance used dogs to search visitor's parcels and handbags. One hospital guard said the hospital's fourth-floor ward had been cleared for the shah, but hospital officials declined to say where he was staying.

Lackland officials originally called a press conference for yesterday afternoon after the shah's arrival. But they canceled the conference without warning and told reporters to leave the base or they would be escorted out.