In a 5-to-4 ruling that finally determined where 800 Montgomery County children will attend classes Sept. 1, the Maryland Board of Education upheld yesterday the county school board's recent and controversial decision to close two popular elementary schools.

The 13 1/2-hour state board session had been prompted in part by outraged leaders of the Rosemary Hills and North Chevy Chase elementary school communities.

Parents had requested a reversal of the local board's July 28 decision to close North Chevy Chase, a magnet school, and move its students to Rosemary Hills.

But the nine-member state panel reluctantly upheld that transfer, as well as contested local board decisions to close Rollingwood Elementary and defer action on the attendance boundaries of Montgomery Blair High School. The state board said that the new school term was too close for any other decision.

"We are approving the county board action on an interim basis . . . ," the five-member majority said. Added state board president Joanne T. Goldsmith, "Our main concern was the education of the children."

The ruling was the latest chapter in an emotional process that began last November with the local board's decision to close 28 schools by 1984 because of declining enrollment.

The state board criticized the local board for giving too little notice to the affected communities. The state board said it will maintain jurisdiction over the fate of the schools.

"There is no indication that there was a budgetary 'emergency' or any other 'emergency' circumstances" that prompted the local board to close two schools and make a difficult transfer of a successful magnet program on such short notice," the state board said. The four state board members who dissented, including a former Montgomery County school board president, were even more critical of the local board, saying "we think the county board's action demonstrates an appalling lack of sensitivity and concern for the welfare of the children involved and dismisses the concerns of the parents and communities with a callous shrug . . . "

Montgomery School board member Carol Wallace quickly took issue with those charges, saying, "Ours was a very strong factual case and, in their opinion, I see very little that deals with the facts." Wallace added that the length of the state's own appeals process should be blamed for the late decisions her board faced.

"We made our decisions last November," said Wallace. "The state had this for seven months and then they say we have to do something before September. Considering the time we had, I think we did pretty good."

Yesterday, some parents said they were discouraged by the state board's actions.

"It's very hard to swallow this and go on," said Sara Mazie, president of North Chevy Chase's Parent Teacher Association. "But we will work very hard to make sure this program works at Rosemary Hills." Attorneys for the parents had argued that the school magnet program would suffer because of the transfer.

The state board directed the local board to develop long-range plans for the Bethesda-Chevy Chase cluster that included Rosemary Hills and North Chevy Chase. The state board ruled that communities should have some say in those plans and that the local board should report its findings to the state board by next Jan. 31.