One of the questions that writers sometimes ask is whether their idea is too similar to another author's. This question implicates both legal and ethical issues.
Copyright is a legal concept that protects a written work (among other things) from direct copying. Copyright law prohibits you from, for instance, reprinting Twilight: New Moon under your own name and selling copies of 'your' book, because in doing so you would be trespassing on the author's copyright as well as the licenses she granted her publisher. You also can't republish a piece of a copyrighted work, so you're not allowed to drop a chapter of Twilight into your book. In the United States, copyright arises at the moment of creation, although the right to prosecute a copyright claim in court does not arise until after a copyright is filed with the federal government. The same is true in many other countries, but not all. There are plenty of places where copyright only arises when it is issued by the government, and there is no truly global copyright law, so be cautious about tossing your work around globally.
The United States recognizes an exception to copyright called "fair use." Whether a use is fair "is an open-ended and context-sensitive inquiry” Cariou v. Prince, 714 F.3d 694, 705 (2d Cir. 2013), which is a legal way of saying "we know it when we see it." U.S. statutory law does, however, recognize a non-exclusive list of four factors that inform whether a given use is fair: (1) the purpose and character of the use, including whether such use is of a commercial nature or is for nonprofit educational purposes; (2) the nature of the copyrighted work (3) the amount and substantiality of the portion used in relation to the copyrighted work as a whole; and (4) the effect of the use upon the potential market for or value of the copyrighted work. 17 U.S.C. § 107.
“In considering the first statutory factor, the primary inquiry is whether the use communicates something new and different from the original or otherwise expands its utility, that is, whether the use is transformative.” Fox News Network, LLC v. Tveyes, Inc., 883 F.3d 169, 176 (2d Cir. 2018). The second fair use factor (nature of the work) requires an analysis of “(1) whether it is expressive or creative, with a greater leeway being allowed to a claim of fair use where the work is factual or informational, and (2) whether the work is published or unpublished, with the scope for fair use involving unpublished works being considerably narrower.” Andy Warhol Found. for the Visual Arts, Inc. v. Goldsmith, 992 F.3d 99, 117 (2d Cir. 2021). The third fair use factor (amount of the use) requires consideration of “the amount and substantiality of the portion used in relation to the copyrighted work as a whole.” Bill Graham Archives v. Dorling Kindersley Ltd., 448 F.3d 605, 613 (2d Cir. 2006). In assessing the final factor in the fair use inquiry (effect of the use,) "we ask not whether the second work would damage the market for the first by, for example, devaluing it through parody or criticism, but whether it usurps the market for the first by offering a competing substitute.” Andy Warhol Found., 992 F.3d at 120.
Plagiarism is different. True plagiarism is an ethical, not a legal offense and is enforceable by academic authorities, not courts. Biswas v. Rouen, No. 18-CV-9685 (S.D.N.Y. 2019). Black's Law Dictionary claims that "Plagiarism occurs when someone--a hurried student, a neglectful professor, an unscrupulous writer--falsely claims someone else's words, whether copyrighted or not, as his own." Kindergartners Count, Inc. v. DeMoulin, 249 F. Supp. 2d 1233, 1251 (D. Kan. 2003). Some courts and most academic journals, however, expand that definition to include not just words, but also ideas. See, e.g., Lionel S. Sobel, The Law of Ideas, Revisited, 1 UCLA Ent. L. Rev. 9, 96 (1994) (defining plagiarism as “[t]he copying of ideas or expression of another author and using them as one's own work”). Plagiarism is thus both broader and narrower than copyright infringement: (1) directly copying someone's work without attribution is a violation of their copyright and is plagiarism; (2) directly copying someone's work with attribution is still a violation of their copyright, but is not plagiarism; (3) copying someone's ideas without attribution is not a violation of their copyright, but is plagiarism.
Importantly, the idea of fair use generally applies to plagiarism as well as to copyright. For instance, under the broadest possible definition of "plagiarism," substantially every book would be plagiarized because it's basically impossible to write without reusing at least one existing trope or genre, which are themselves 'ideas.' No one can meaningfully accuse you of plagiarism for using a trope, and of course accusing someone of plagiarism because they've written in a given genre like 'romance' wouldn't pass the laugh test. There are also some canonical works that are so well-known that reinterpretations of them aren't generally considered plagiarism. Most people wouldn't call Bridget Jones's Diary or Bride and Prejudice 'plagiarized,' for instance, even though both are beat-for-beat duplicates of Jane Austen's Pride & Prejudice.
And, like copyright, including a short quote from a more famous work, particularly when its source is well-known, is generally not considered plagiarism: an author whose female lead tells her boyfriend that hell hath no fury like a woman scorned, isn't committing plagiarism both because we all know the original author and, also, because the short quote falls within the rules for fair use (although the cliche would probably be bad writing.) A random quote probably pushes the line, however, because the reader won't recognize it as a quote or homage. An author whose fantasy protagonist says come, go with me: I will go seek the king is coming much closer to plagiarism because it's a quote from a work of fiction, the quote isn't really transformative of the original, and few readers will recognize the quote as from Hamlet Act II Scene 1. (NB: Shakespeare's work has fallen into the public domain in most countries, so even a direct copy of one of his plays wouldn't violate his copyright, but would still be plagiarism.)
If you've read to here and still don't know whether your work runs afoul of copyright or plagiarism rules in your markets, consider asking an editor for their opinion before you publish. You can also let critiquers know that you're worried and ask for their opinion. Happy writing!