Students at the University of the District of Columbia voted last night to accept an agreement with the university's trustees, ending a 10-day takeover of a campus building that had shut down the school.

The unanimous endorsement of the agreement came within minutes of what a trustee source said was an 11 p.m. deadline that would have meant the withdrawal of the pact.

Shortly after the dramatic vote by the movement's rank and file, which endorsed an agreement by the protest's leaders and the trustees, students began filing out of Building 38, the Student Affairs Building. A student leader said that classes would resume Tuesday.

The agreement ratified last night fell short of the students' main demand, resignation of all 11 trustees appointed by the mayor or the D.C. Council.

However, the city's mayor-elect is to review the composition of the board in December. Under the agreement reached between the two sides last night, trustees said they are to be "significantly guided" by the mayor's decision on whether they should retain their seats.

In addition, trustees and students are to lobby the council to expand the board by 10 members. At least two are to be students.

Imposition of the 11 p.m. deadline for acceptance of the offer was apparently connected to fears by the board that student leaders had begun to lose control of the situation.

"It's been apparent to us that we have wonderful students that we have been dealing with all week," a trustee source told a reporter. "But they lost control." Speaking of the other students occupying the building, the source said, "it became too fun for them. The group there will not even listen" to the student leaders.

After the announcement of the student vote, student leader Mark Thompson told reporters that the protesters had shown that activism is alive at UDC.

"No longer will we be able to be called apathetic or unconcerned," Thompson said. "We've changed our situation for the better."

The Rev. A. Knighton Stanley, who has emerged in recent days as a leader of the board, agreed. "Students have been fierce negotiators," said Stanley, a pastor at the People's Congregational Church in the city's Brightwood section. "I've never dealt with finer minds. Sometimes their vision for the future was a little different than ours." He said he was saddened that "we have further politicized this university . . . . I'm going to be out here with the students rejoicing."

The students gave their endorsement last night to what was the second tentative agreement reached by negotiators in two days. The first agreement was worked out in a bargaining session that ended at 2 a.m. yesterday.

About 11 a.m. yesterday, it appeared that adoption of that agreement was imminent. Stanley was called to campus to sign the pact.

In the late afternoon, one group of student protesters voted on the agreement and endorsed it. But it was decided, according to the trustee source, that another vote should be taken. In this vote, taken in the early evening with participation of a larger group of students, the agreement was rejected.

That set the stage for last night's events. As the minutes counted down toward the 11 p.m. deadline, trustees waited tensely for word of the students' action.

A few minutes before the hour, trustees were told, according to the source, that two prominent members of the clergy in the city, Bishop George Augustus Stallings Jr. and the Rev. Willie Wilson, had made an impassioned plea to the students urging acceptance.

Shortly after 11 p.m., security personnel told the trustees that a loud cheer could be heard from the occupied building.

The pact adopted is similar to one that was disclosed Thursday, which called for improvements in academic and athletic department programs and amnesty for students if they voluntarily leave the occupied building without destroying property.

The new agreement also includes a statement from trustee Richard Gross apologizing to students for remarks he made during a nine-hour negotiating session earlier this week.

On Wednesday, students released to the media part of an audiotape of a negotiating session in which they said Gross made several disparaging remarks about the university.

The release of the recording incensed several trustees. Some of them said the students had violated their trust. The publicizing of the tape led to a particularly contentious day of negotiations Thursday. At one point, Stanley withdrew his resignation, but later resubmitted it.

However, the seven remaining trustees who were appointed by the mayor said the move to release the tape only deepened their resolve not to resign.

And for the first time since trustees entered into negotiations with the students, the trustees had begun to discuss ways to remove the students from the building.

Since the takeover on Sept. 26, three appointed trustees have resigned. They are Chairwoman Nira Hardon Long and Arthur M. Reynolds and Stanley. Alumni trustees Joseph Webb and Alonza T. Evans also have resigned. All the resignations except for Long's are effective March 31, 1991.

Another trustee, Lourdes Miranda, stepped down in August.Staff writer Keith Harriston contributed to this report.