Puerto Rican labor leaders, religious groups and politicians generally reacted favorably today to the announcement that President Carter has decided to free four island nationalists imprisoned for terrorist attacks in the 1950s.

In an avalanche of statements, after word of Carter's action was received, island leaders such as pro-commonwealth advocate Miguel Hernandez Agosto said it was "time that their spirits and their minds should be free."

However, Gov. Carlos Romero Barcelo, who opposed release of the four prisoners becasue of concern over whether they would stir up nationalist feelings on their return to Puerto Rico, warned the four about a future role in island politics after a two-decade absence.

"Even though my position differs from President Carter's, I trust that the president's decision was correct," the governor said. He added that he believes the prisoners -- Oscar Collazo, Lolita Lebron, Irving Flores Rodriguez and Rafael Concel Miranda -- will "honor" the trust bestowed on them by the persons who sought their freedom.

While four of the commonwealth's former governors had campaigned for release of the prisoners, Romero Barcelo had said repeatedly that the four should ask for a presidential pardon and vow to stay out of island politics.

The prisoners do not recognize U.S. sovereignty over themselves or the commonwealth, and had refused to apply for parole.

If he is reelected next year, Romero Barcelo has promised to hold a plebiscite in 1981 on the island's future status.

He has said he will ask Congress to make Puerto Rico a state if 51 percent of the voters back statehood.

Antonio Quinones Calderon, the governor's press aide, said the release of the four nationalists is not expected to change the island's political future and will not affect the plebiscite.

But the nationalists were expected to receive a hero's welcome on their return. When that might be was uncertain.

The families of the four prisoners, whose release could come as soon as Monday, expressed surprise and jubilation at Carter's decision.

Even Romero Barcelo seemed taken by surprise, although aides said he knew of a Justice Department report recommending the release.

"It's about time," said former governor Roberto Sanchez Vilella. Another former chief executive, Luis Munoz Marin, expressed "profound satisfaction" at the move by Carter.

Serapio Laureano, president of the island's teachers association, said the four nationalists were "fine examples for the youths to emulate in defense of our values."

Collazo was imprisoned for a 1950 attempt on President Truman's life. The other three prisoners wounded five legislators in a 1954 shootout from the House visitors' gallery.