Agent 160 received her first assignment in 1666. The newly minted spy for the English government, also known as “Astrea,” had a simple task: find a soldier named William Scot in the Netherlands—enemy territory—and convince him to turn spy for Charles II. Agent 160 had £50 with which to do so.

But between the cost of travel, the unfavorable exchange rate between the pound and the guilder, and the spy’s inexperience, she quickly ran out of money. No amount of pleading could induce the English government—already flirting with bankruptcy—to give her more. So the spy whose true name was Aphra Behn turned to an equally unlikely profession to save herself from debtors’ prison: writing.

The social world that allowed a woman to be first a spy, then a financially successful playwright and poet was one of enormous upheaval. Charles II came to power in 1660 after England spent 11 years without a king. During that period, known as the Interregnum, Oliver Cromwell and others led a series of republican governments and promoted puritan moral standards. Charles’s reign ushered in the Restoration, which continued under his successor and brother, James II, until 1688, when it ended abruptly with an armed overthrow.

Despite the political turmoil that ensued—England ended up going to war with the Netherlands in the Third Dutch War in 1672, and both countries were filled with spies on the lookout for plots to overthrow Charles—the Restoration was also a heady period of libertinism and pleasurable pursuits. In 1660, theaters reopened after years of being shuttered by Cromwell, and writers and audiences alike flocked to the stage. “The stereotyped image of Restoration comedy was… a witty, urbane, London-based comedy, probably containing illicit sex; a form of comedy which started with the arrival of Charles II, a witty, urbane king dedicated to illicit sex,” writes Derek Hughes in The Cambridge Companion to Aphra Behn.

Or as literary scholar Janet Todd writes in her biography of Behn, “At home in his rambling, dirty palace of Whitehall, Charles II seemed to be presiding over a perpetual masquerade party.”

It was the perfect environment for a woman like Behn. Little is known for certain about her early life, though sources suggest she was born in 1640, the daughter of a barber and a wet nurse who breastfed the children of more socially elevated families. As a young woman, Behn traveled to Surinam, a plantation colony in South America the Dutch seized from England during the Second Anglo-Dutch War. That trip served as fodder for her later writing, especially Oroonoko, or the Royal Slave, a work of fiction sometimes considered the first novel that argued for the abolition of slavery.

Behn married at some point, though it seems her husband died shortly after their marriage, perhaps in the Great Plague that struck London in 1665-66. With no husband, Behn found her way into spycraft. But she was unsuited for the work, and after leaving the Netherlands, Behn turned to her pen to provide a living. She quickly made a name for herself.

In 1670, Behn’s first play was produced in London. The Forc’d Marriage tells the story of a heroine ordered to marry someone she doesn’t love. After a series of twists and turns—brushes with infidelity, a faked death, several sword fights—all the characters end up with the people they love. She wrote “in the bawdy mode of the Restoration,” making frequent references to sex and both male and female pleasure, says English scholar Dorothy Mermin.

Take, for example, the innuendo-laden speech given by one of the women in The Forc’d Marriage: “With more facility than when the dart, arm’d with resistless fire first seiz’d my heart; ’twas long then e’er the boy could entrance get, and make his little victory complete; and now he ’as got the knack on’t, ’tis with ease he domineers, and enters when he please.”

Similar double-entendres occur throughout Behn’s works, and her stories of love and lust were wildly popular with Restoration audiences. According to Todd, Behn was second only to the Poet Laureate, John Dryden, in works produced. She even earned the patronage of the Duke of Buckingham and James II. But that didn’t change the fact that Behn was a woman in a man’s world.

“Merely to appear in public—to publish—has generally been held discreditable for women,” Mermin writes. Behn had to fight the perception that it wasn’t a woman’s place to write for money. In the preface to one of her plays, she wrote, “The play had no other misfortune but that of coming out for a woman’s: had it been owned by a man, though the most dull, unthinking, rascally scribbler in town, it had been a most admirable play.”

Behn only lived until 1689, and her work provided a path for other female playwrights like Catherine Trotter, Mary Fix and Susannah Centlivre. But in the following decades, despite her fame, Behn was scorned by critics who found her writing too smutty and scandalous for a woman. As Mermin says, Behn’s “notoriety survived into the nineteenth century as both example and warning.” She was dismissed as a hack by critics, including 18th-century poet Alexander Pope, and called outrageous for her frank treatment of sex and relationships..

“The stage how loosely does Astrea tread,/ Who fairly puts all characters to bed!” Pope wrote, criticizing Behn’s use of sex to illustrate the relationships between men and women. Later, in 1865, a scholar said Behn “might have been an honor to womanhood—she was its disgrace. She might have gained glory by her labors—she chose to reap infamy.”

But by the end of the 19th century, 200 hundred years after her death, Behn’s success once more earned her praise—this time from Virginia Woolf. “All women together ought to let flowers fall upon the tomb of Aphra Behn, for it was she who earned them the right to speak their mind,” Woolf wrote in A Room of One’s Own. More and more scholars returned to her works, seeing in them the beginnings of feminism. As one scholar notes, “In their ironic treatment of female chastity and masculine constancy…her comedies present a sophisticated and sympathetic understanding of the ideological complexities of women’s existence in a misogynistic society.”

And while Behn’s name isn’t as recognizable as Shakespeare, Chaucer, or other English male writers, her work laid the foundation for women whose names are recognized, like Woolf herself.