Cuban President Fidel Castro is expected to free the last imprisoned senior officer of the ill-fated Bay of Pigs invasion early Sunday, according to congressional aides who assisted in the release.

Ricardo Montero Duque, 60, who has served 25 years of a 30-year sentence and was one of six battalion commanders in the failed, CIA-sponsored effort to oust Castro in 1961, is to be released at dawn from Combinado del Este prison near Havana, the sources said.

Montero's expected release comes amid reports of other political prisoners being freed in Cuba recently and raises questions about whether the releases suggest an effort by Havana to improve relations with Washington.

Montero is to be flown directly from Havana to Homestead Air Force Base in southeast Florida on a chartered plane, to be reunited with his 80-year-old mother and other relatives.

Castro is freeing one of his oldest and most resolute enemies in response to a 16-month effort by Sen. Edward M. Kennedy (D-Mass.).

Responding to a separate appeal by French explorer Jacques Cousteau, who visited Cuba late last year on a diving expedition, Castro is believed to have freed 27 other political prisoners on May 10 from several Cuban jails, the head of a Cuban-American research center in Washington said. Frank Calzon, director of the Cuban American National Foundation, said all of them are believed to remain in Cuba.

Administration officials confirmed that "more than 10" political prisoners had been released in recent weeks in Cuba. One official said it is too soon to tell whether the releases signal a new move by Castro to warm up his now frozen relations with the United States.

"It's very difficult to know why he does these things," said one administration Cuba-watcher.

But some observers here and in Washington think Castro is testing the waters for further measures to break a year-old impasse. In December 1984 Cuba and the United States signed a broad immigration agreement allowing freer movement of Cubans between the two nations. Castro agreed to take back 2,746 convicted criminals or mental patients who had left the island in the 1980 boatlift from the port of Mariel.

But the Cuban leader abruptly broke off the agreement when the U.S. government's Radio Marti went on the air broadcasting anti-Castro messages in May 1985.

Officials said the administration is eager to renew the agreement.

Castro, Calzon said, appears to be freeing some prisoners to provide a political counterbalance to strict domestic measures he adopted last month, closing all small farmers' markets and other free trade activities in rural areas.

A Kennedy aide who visited Montero Thursday at a prison clinic reported that he is in "relatively good shape" physically and mentally.

Montero was one of a small number of political prisoners who refused to wear a prison uniform and participate in government "reeducation programs." He is believed to have served most of his term wearing nothing but underclothes.

In recent years he was allowed one personal visit every four months.

"He never recanted, never signed a forced confession, never changed his position," said one Kennedy aide. "He's hard core."

The Cuban American National Foundation learned of prisoner releases after two Cubans approached the U.S. Interests Section in Havana recently carrying letters they had received from Cousteau wishing them "good luck in your new life." They said they were part of a group of recently freed long-term political prisoners.

Cousteau met with Castro late last year to petition for at least three prisoners, after 38 U.S. congressmen wrote him a letter urging him to do so.

Montero was one of 14 Bay of Pigs combatants Castro refused to release to the United States when almost 1,200 others were freed in December 1962 as a result of efforts by President John F. Kennedy and his brother Robert. Montero had served as an officer in the Army of toppled Cuban dictator Fulgencio Batista, exiled members of his battalion said in Miami.

After Montero is liberated, only one other Bay of Pigs veteran will remain in prison. Ramon Conde Hernandez led an anticommunist political group in Cuba before Castro ousted Batista in 1959, and was also singled out for special punishment.