BUDAPEST — Daniel Szabo and Gergo Birtalan are both optimistic about their job prospects in their native Hungary, which has a low unemployment rate for college and university graduates. But the two Hungarian students are in totally different situations.

When Mr. Szabo, 24, graduates soon from law school, he will be free to go wherever in the world he wants. But Mr. Birtalan, 18, was required to sign a contract at the beginning of his first year as a sociology major because of a new rule introduced in September. As a beneficiary of the state-funded university system, he will be obliged to work for two years in Hungary for every year of his subsidized studies.

Such contracts, the only ones of their kind in Europe, have met with broad opposition and street protests from both high school and university students.

If Mr. Birtalan finishes a typical three-year degree, his movements will be restricted for six years after graduation, when he will be in his late 20s, or even older if he pursues post-graduate studies domestically. The rule applies to all students at state universities, as well as those at state-funded places in private institutions.