The Montgomery County teachers union and the Board of Education reached tentative agreement last night on a contract that will give the county's 5,600 teachers raises of 6 1/2 percent next year and 5 percent the following year.

Tentative agreement on the two-year contract followed more than three months of often-bitter negotiations and leaves the teachers with raises that as late as early last night were characterized as "totally unacceptable" by David Eberly, president of the union, the Montgomery County Education Association.

The agreement was announced as the board was in the final stages of considering its budget proposal--expected to total $357 million--for the next school year. A March 1 deadline for submitting the budget to the County Council contributed to a sense of urgency in the contract negotiations.

The $357 million figure represents almost a 7 percent increase over current school spending and exceeds by almost $4 million the budget guideline recommended by County Executive Charles W. Gilchrist.

Although teacher union representatives pledged to work "loyally" to gain ratification of the contract from union members, Eberly said he was "not overjoyed" by the settlement.

"The board has been extremely rigid throughout the negotiating process," a weary-looking Eberly said moments before the agreement was announced, "but we came to the conclusion that we had gotten everything that we possibly could from this board. It's been no secret that I have felt that this board has been bad for the school system and bad for us."

The contract agreed to last night was recommended by a mediator early this month.