Melvin Udall is a successful author who lives the life of a recluse. He is a misogynistic, homophobic, anti-Semitic racist with an intense dislike of people and dogs. All the neighbors in his Greenwich Village apartment building avoid him.
His psychotherapist diagnosed Melvin with OCD (obsessive-compulsive disorder) because he avoids stepping on sidewalk cracks and touching other people, wears gloves all the time, wipes off door handles, eats at the same restaurant every day, sits at the same table, insists on the same waitress, Carol, and always orders the same meal.
Suddenly, Melvin's life takes a turn. His artist gay neighbor, Simon, is beaten up by a group of robbers. Simon's art dealer, Frank, forces Melvin to care for Simon's dog during his owner's recovery. Soon Melvin encounters another challenge, because his waitress is not at her job one day when her son is sick. He expresses his frustration, and is finally thrown out of the restaurant, followed by applause from the regulars. Melvin finds out where Carol lives and visits her. He offers to pay a doctor to care for the sick son if she promises to wait on him again.
Gradually, Melvin discovers his love for Carol and the little dog in his care. After coming to terms with his own failings, he starts to experience and demonstrate compassion. Of course, he does not change overnight, and there are times when the old Melvin Udall rears his ugly head, leading to many plot complications.
At one point, Carol and Melvin have a date at a fancy restaurant, only to discover that Melvin needs to purchase a coat and tie to meet the dress code. Challenged by these demands on him, he insults Carol, saying that she is wearing a housedress. She gets furious and demands a sincere compliment, or she will leave the restaurant. With anguish and many disclaimers, Melvin finally states that because of his affection for her, he decided to take medication for his OCD. When Carol wants to know why that is a compliment, he says that being with her makes him want to be a better man. When Carol responds very positively and affectionately, he tries to take it back by saying that he "overshot the mark".