NEW YORK — College students who began the year being taught by ill-prepared substitutes were back with their regular professors Thursday after Long Island University ended a faculty lockout at its Brooklyn campus caused by a bitter contract dispute.

About 400 professors and adjuncts at the school scrambled to get back to work after their union, the Long Island University Faculty Federation, struck an agreement late Wednesday to extend their contract until May 31, 2017.

The lockout, which began a few days before classes were to start on Sept. 7, left professors without health insurance or access to email. It also deprived about 8,000 students of their teachers.

School administrators temporarily replaced the professors with substitutes, who many students called unqualified.

Some ended class quickly after attendance was taken or a syllabus was handed out, students said. Science labs were canceled because instructors didn’t have required safety licenses.

It was unclear whether either side gained anything from the lockout.

As part of the agreement to get professors back to work, the faculty promised not to strike during further contract negotiations. The union also accepted a proposal to engage a mediator.

The university’s chief operating officer, Gale Haynes, said the union’s commitment not to strike “provides us enough runway to reach a reasonable and fair agreement, while providing our students the ability to continue their studies uninterrupted.”

Professors had rejected a proposed contract that would have cut salaries and hours for new adjunct professors, who represent about half the teaching staff, while offering existing faculty average raises of more than 13 percent over five years.

The faculty federation, affiliated with the American Federation of Teachers, has filed a charge of unfair labor practice against the university with the National Labor Relations Board, alleging bad-faith bargaining.

The university also has a Long Island campus, which was unaffected by the labor troubles.

Another sticking point in negotiations was that tenured professors at the Brooklyn campus are paid less than those at its Long Island campus, LIU Post.

LIU spokeswoman Jennifer Solomon said the differences in salaries between the Brooklyn and Long Island faculty are a result of salary structures requested by the union in previous contracts.