I invent my characters, especially minor ones, as products of need and plot. For example, my protagonist is conducting an environmental protest at a remote goldmine and no one comes. In order to turn a mildly unusual situation into chaos and pandemonium, I imagined a security guard with a speech defect coupled with a situation where he needs to call 911. To make him believable, I painted him with traits one might expect given his situation and condition--but also dropping comments and taking actions that reveal there's more to the man than a stereotypical mold.
My main characters tend to be wedded to the process of my imagining the overall story, so they're still products of need and plot. The difference is 'something' tells me their voice and actions need to be part of the tale. When I envision the story, they're already in it. They seem like real people in my mind, so in the interest of 'doing them justice' I work to make them real in the minds of my readers. This can include imagining what their personal histories 'must' have been and painting their personalities with conflicting colors (since we so often harbor conflicts).