Yet at the same time, undocumented students say they have been made to feel unwelcome. At last year’s rally, a student who is a member of a campus conservative group approached Mr. Zelaya and bluntly told him that he had reported him to the federal immigration authorities. In 2010, the student senate passed a bill opposing the state law that allows illegal immigrants to qualify for in-state tuition rates at public colleges and universities, though it was vetoed by the student body president.

And while Mr. Zelaya spent no money on signs or a Web site for his campaign — one of his rival candidates spent $900 on T-shirts — some students were reluctant to vote for him, either because of his immigration status or because they felt he would be more of a minority advocate than a student advocate.

“A lot of people were worried that someone who isn’t completely following the law might be representing our university,” said Thomas McNutt, 21, who also ran for student body president. “Whether you agree with the undocumented student issue or disagree with it, the law is the law as it is right now.”

Justin Pulliam, who graduated in December and was a co-founder of Texas Aggie Conservatives, the group whose member notified immigration officials last year and which endorsed Mr. McNutt for president, put it another way. “Most Texas A&M students don’t want a taxpayer-funded illegal immigrant activist to hijack the student body president’s office in order to advance a pro-amnesty agenda,” said Mr. Pulliam, 22, who pointed out that student candidates in the past had been criticized for minor run-ins with the law. “These candidates have been attacked and discredited, but now people are celebrating when an out and proud illegal immigrant runs to lead the student body.”

While many undocumented students found Mr. Zelaya’s campaign inspiring, his defeat was a reminder to some of the difficulties they face gaining widespread acceptance on a campus that last year came in third in the Princeton Review’s rankings of colleges with the most conservative students. “I think we could have won” the election in any other university, said Greisa Martinez, 23, an undocumented student who co-founded a group with Mr. Zelaya called the Council for Minority Student Affairs. She said a Hispanic student told her of being in a class during which the professor, discussing the growth of Hispanics in Texas, said the state could have a Hispanic governor in the future. A number of students in the class hissed.