SAN JUAN, Puerto Rico — A U.S. judge said Monday that the federal government is violating the Constitution by prohibiting people who live in Puerto Rico from receiving Supplemental Security Income.

The opinion was issued as Judge Gustavo Gelpi dismissed a lawsuit filed by the federal government seeking to recover more than $28,000 in SSI disability benefits paid to a U.S. citizen after he moved from New York to the U.S. territory of Puerto Rico.

Gelpi said a clause in the Constitution that allows federal legislators to enact rules and regulations for U.S. territories is not "carte blanche for Congress to switch on and off at its convenience the fundamental constitutional rights to due process and equal protection."

"Congress, likewise, cannot demean and brand said United States citizen while in Puerto Rico with a stigma of inferior citizenship to that of his brethren nationwide," Gelpi wrote, adding that powers granted under the Constitution are not infinite.

The ruling involved the case of Jose Luis Vaello Madero, who lived in New York from 1985 until 2013, when he moved to Puerto Rico. He continued to receive payments until 2016, when he was told he was ineligible. The Social Security Administration then filed civil action against him in 2017 demanding he return the funds he received.

SSI benefits are awarded to help elderly, blind and disabled people who are struggling economically. The benefits are available to any U.S. citizen living in any of the 50 states, Washington, D.C., and the Mariana Islands. However, Puerto Rico, the U.S. Virgin Islands and Guam are excluded, while American Samoa is not eligible.

Puerto Rico instead has a program called Aid to the Aged, Blind and Disabled. To qualify, people have to make $65 or less a month, compared with $750 monthly for SSI. In addition, the average benefit received in Puerto Rico under that program is $77 a month, compared with $533 with SSI. The island of 3.2 million people has a poverty rate of more than 40 percent, higher than any U.S. state.

Jenniffer Gonzalez, Puerto Rico's representative who has limited voting rights in Congress, welcomed Gelpi's ruling. She filed legislation on Monday that would extend SSI benefits to Puerto Rico, whose residents have been U.S. citizens since 1917 but are barred from voting in general elections.

"Our families cannot be worth less than those who live in the United States or other territories," she said.

The U.S. government has argued that including Puerto Rico in the SSI program would be too costly, saying people on the island do not pay federal income tax, which funds the program. But Gelpi said that a significant percentage of U.S. citizens in Puerto Rico have to pay federal taxes, and that "when it comes to SSI, neither group in reality contributes to the federal treasury due to the fact that its beneficiaries are poor and needy."