Aaron Schock, the Republican who resigned from Congress in 2015 as he faced questions about his adherence to spending rules, came out as gay on Thursday, writing in a lengthy post on his website about the challenges of growing up in a religious household and saying he was wrong to oppose gay marriage.

“The fact that I am gay is just one of those things in my life in need of explicit affirmation, to remove any doubt and to finally validate who I am as a person,” Mr. Schock wrote.

Mr. Schock, of Peoria, Ill., was elected to Congress in 2008, when he was 27, and was once seen as a rising star in the Republican Party. He came under criticism in 2015 for lavish spending, including a redesign of his Capitol Hill office. It included blood-red walls, a crystal chandelier and a plume of pheasant feathers, and was rumored to have been inspired by a room on “Downton Abbey.”

He was indicted by a federal grand jury in 2016 on 24 counts, including wire fraud and theft of government funds. Federal prosecutors reached an agreement in March 2019 to drop the charges. Mr. Schock vowed to pay back taxes and reimburse his campaign.