Margaret Thatcher and Indira Gandhi have pretty much laid to rest that old shibboleth that "women aren't tough enough to become national leaders", but they have a compatriot, far earlier in time, less known, but operating in what was undoubtedly an exponentially more difficult and dangerous environment. Her name was Ranavalona, and her title Queen of Madagascar. She reigned from 1828 to 1861, dying peacefully in her bed of old age, having kept her country independent despite the best efforts of the French and the English.
No, I hadn't heard of her either, but the story of her rise to power, and her maintenance of it for 33 years, is quite a tale. For she was not some accidental queen, falling into power by birth or marriage. She was not even born royal, but was the adopted daughter of the dynasty-founding king Andrianampoinimerinandriantsimitoviaminandriampanjaka. (No, I didn't have my elbow on the keyboard; that was his name, meaning "the beloved prince of Imerina who surpasses the reigning prince".)
That adoption came in recognition of the services her father had rendered to the monarch, and she became the wife of his son, Radama. (For the Ancient Egyptian custom of brother-sister marriage was followed by the ruling Merina dynasty.) But they seem not to have got on — the fact that he executed several of her close relatives when he came to the throne might have had something to do with that — and she never bore him a child.
When King Radama died, her position was potentially deadly. The rightful heir to the throne, by long tradition, was the eldest son of his eldest sister, Prince Rakatobe, and he was no friend of Ranavalona. If she were to bear a male child, by any father, even after the death of the king, he would theoretically be a legitimate claimant to the throne. There was little doubt that Rakatobe, given the throne, would ensure, very finally, that could not happen.