* Sides accuse each other of shelling
* Concern mounting as humanitarian ceasefire frays
* Fighting over Nagorno-Karabakh is heaviest in decades (Adds day's events and context)
By Nailia Bagirova and Nvard Hovhannisyan
BAKU/YEREVAN, Oct 17 (Reuters) - Armenia and Azerbaijan said they had agreed on Saturday to a new humanitarian ceasefire from midnight (2000 GMT) in fighting over Azerbaijan's ethnic Armenian-controlled enclave of Nagorno-Karabakh.
Azerbaijan and Armenia had accused each other earlier on Saturday of fresh attacks in violation of a week-old Russian-brokered truce that had failed to halt the worst fighting in the South Caucasus since the 1990s.
Azerbaijan had said that 13 civilians had been killed and more than 50 wounded in the city of Ganja by a missile attack from Nagorno-Karabakh. Armenia, which supports Nagorno-Karabakh politically and economically and sends volunteers to serve in its army, had accused Azerbaijan of continued shelling.
The fighting is the worst in the region since Azerbaijan and ethnic Armenian forces went to war in the 1990s over Nagorno-Karabakh, a territory that is internationally recognised as part of Azerbaijan but populated and governed by ethnic Armenians.
Both countries announced the ceasefire in identical statements.
Russian Foreign Minister Sergei Lavrov, who mediated the ceasefire talks a week ago, had talked to his Armenian and Azeri counterparts by phone on Saturday and stressed that the truce agreed a week ago must be observed, Moscow said.
Russia, France and the United States are members of the Minsk group, which has attempted to help resolve the long-running conflict under the umbrella of the Organisation for Security and Cooperation in Europe (OSCE).
Nagorno-Karabakh's foreign ministry said in a statement after the announcement: "We welcome the efforts of the OSCE Minsk Group Co-Chairs as well as Armenia to achieve a ceasefire in the Azerbaijani-Karabakh conflict zone as well as to reduce tensions.
"Nagorno-Karabakh reaffirms its readiness to maintain the terms of the humanitarian ceasefire on a reciprocal basis ... according to the Moscow statement of Oct. 10 and the agreements of Oct. 17."
French President Emmanuel Macron said the ceasefire must be "unconditional and strictly respected by both sides", according to a statement from his office.
Armenia speaks to Baku on Nagorno-Karabakh's behalf as Azerbaijan refuses to negotiate with the separatist authorities.
Yerevan says its armed forces are not involved in the conflict and have not launched any attacks towards Azerbaijan. Many Armenian citizens, including the prime minister's son, serve in Nagorno-Karabakh's army on a voluntary basis. (Additional reporting by Umit Bektas and Bulent Usta in Ganja and Ali Kucukgocmen in Istanbul; Writing by Margarita Antidze and Kevin Liffey; Editing by Pravin Char)