Councillors in Moray have voted to retain three libraries that were earmarked for closure, but four others will shut.
Members voted 13 to 12 to reprieve Cullen, Burghead and Dufftown but to close Hopeman, Portknockie, Findochty and Rothes.
Campaigners had pointed to warnings by council officials that vulnerable groups would be adversely affected by closing the libraries.
The cuts were aimed at saving £350,000.
The council announced earlier this year it would close the seven facilities.
However campaigners opposed to the closures threatened legal action, based on the warning from officials, raising the possibility of a lengthy and costly case.
Councillors rejected a motion to spare all seven libraries.
The campaign group Save our Libraries Moray will now take further legal advice.