Administrators at a Long Island high school forced a student to sign a contract barring her from changing her gender identity because she had switched it twice already, sources told The Post.

Born a girl, the current Valley Stream South High School student, who asked to remain anonymous, said she first asked the school to recognize her as a male with a new name as a sophomore last year.

A school social worker told her that hesitant administrators wanted her to delay the change until this year — purportedly because the process was lengthy and complicated.

“That wasn’t true and I knew it wasn’t true,” the student told The Post. “After I insisted on it, they made the change in a few days.”

Formally regarded as a boy last year, the student said her teachers and classmates accepted her new identity and made her feel comfortable.

She was addressed by her new male name in class and changed in a nurse’s office to avoid any bathroom conflicts.

But the student decided to revert to being a female before the beginning of this school year because a younger relative who didn’t know about her change was set to enter the school.

“My parents and friends knew but some of my other relatives — mainly my grandparents — didn’t know,” she said. “I was worried that this relative would tell them and I just couldn’t deal with that at this point.”

Her guidance counselor agreed to again categorize her as female — but then handed her a contract to sign promising that she would no longer switch genders while at the school.

The student agreed but felt she should never have been put in that position. “They should have just supported me in my decision either way,” she said.

“A student should feel safe to figure their identity out no matter how many times they change who they are.”

Now a gay female again with her original name, the student said she is likely to remain a woman for the foreseeable future.

“I just came to the realization that gender is not a big deal either way,” she said. “People can think of me however they want. It’s not important.”

When asked about the contract, superintendent Bill Heidenreich said, “The district fosters a positive environment that promotes acceptance and respect for all. Any allegations made against our administration are taken very seriously. They are thoroughly investigated and any appropriate disciplinary action is taken when necessary.”