The movie opens in flashback to about 1980 at a fair in Indiana of some sort with pie eating contests, etc. The camera settles on a boy magician named "Harry the Great", who is about to perform a trick when he saws a girl in a box in half with a chainsaw. Midway, the girl lets loose with a series of piercing screams, panicking the audience and some nearby adults who rush up and open the box. The girl was just pretending to be hurt and smiles up at the adult man professing "I'm going to be an actress" before he slaps her.
The movie cuts to a generic Hollywood beautiful person party where we see Harry (Robert Downey Jr.), fully but shabbily clothed, intentionally teetering at the edge of a pool full of bikini clad women. At this point the narrator (Harry) introduces himself and apologizes, somewhat defensively, for not being very good. "Do you see any other narrators?" he asks. (The movie repeatedly revisits the idea that the narrator isn't a trustworthy source. The symbolism is that the pool represents the Hollywood lifestyle and he's trying to decide whether to jump in or not). He (as the narrator) asks us if we want to know how he got here.
We now cut to a small toy store late at night. Two thieves are rummaging around. One of them, Harry, is on the phone with his niece as she describes the action figure ("CyberCop") she wants for Christmas. Harry pretends that the store is open and he's on a regular shopping expedition, but his niece isn't buying it (it's too late at night). A large UPS truck drives by, jostling the wiring on the jury rigged alarm and setting it off. The two run out the back door and into an alley, where they are fired upon by a woman on a fire escape. Harry's partner is hit, but Harry escapes on foot as the police approach. He runs from alley to alley until he encounters a milling group of men who are all dressed in dark thiefish clothing like himself. He runs up a stairway and crashes into a room with 3 or 4 people sitting around a desk. A woman tells him they're not ready for him yet, but another man, a Larry Miller-ish casting agent (played by - who else - Larry Miller), tells him to go ahead and hands him a script. It's from some sort of hard boiled crime thriller in which the main character is being berated for allowing his partner to be killed. Harry stumbles through it for a couple of lines before the similarity to his current situation gets to be too much and he loses it, throwing a chair and putting his head on the lap of one of the casting agents and begging forgiveness. At this moment a cop bursts through the door, before apologising for interrupting and ducking back out. Larry Miller says he's found what he's looking for and hires Harry for the part suspiciously quickly - his motives become clear much later...
Meanwhile, back at the party, a woman (Michelle Monaghan) named Harmony is introduced by the narrator, who dips a little into her back story through a few brief flashbacks - noting that she is from a small town, likes reading a crime series about a detective called "Johnny Gossamer", and alluding to the fact that their father may have sexually abused her sister Jenna. The narrator then realizes that he isn't explaining how she got to the party, which he then goes into, the reason involving an actor from a cancelled TV show about a robot who drunkenly broke into her house in his costume. Long story short, she gets invited to the party, where she is seen going over the bookshelves in the house until she finds some copies of the same old paperback detective series - "Johnny Gossamer". She hugs them tenderly, reads from them for a bit and then passes out on a table. A sleazy man enters and, seeing her unconscious - starts to poke around in her underthings before Harry walks in. Harry tries to intervene but ends up being beaten to a pulp - reflecting he never was very good at fighting. After the man walks away, Gay Perry (Val Kilmer) helps Harry up. He tells Harry he's a high end private detective who's been hired by the films producers to train Harry in the ways of private detecting. He takes him into the bathroom and helps him clean up. Harlan Dexter (Corbin Bernsen) pokes his head in and introduces his daughter, who is getting ready to cut her birthday cake. She has apparently been in Europe for many years and threatening to sue her father over her deceased mother's money, but they've patched things up and are all nicey-nicey.
Gay Perry is getting ready to leave the party when Harry asks him about the woman. Perry recognises her and recommends Harry go to the Domino bar, which he does.
Harry shows up at the club and walks past the doorman without being hassled. He encounters a woman named Flicka (Angela Lindvall) has a brief conversation (she tells him she's a stewardess, he lies and tells her he's a PI (important later). It takes about an hour. The woman from the party is sitting at the bar. Harry sits next to her and launches into conversation. They flirt a little bit with her suggesting Harry take up with the woman across the bar who's 35 and still attempting to act. Harry asks her how old she is and she says she's 34. Harry starts to walk away after a little banter, but she calls him back. She can't believe he doesn't recognize her. She's his childhood friend Harmony (the girl being sawed in half at the beginning of the movie by young magician Harry). Harmony's friend shows up and becomes very hostile - trying to drive Harry off. Harmony calms her down and Harmony and Harry head to a table.
Harmony describes growing up in Indiana parallel to Harry. She was turned onto the Johnny Gossamer books by reading them to her invalid mother. Her father was a child molester who abused her younger sister while she stood helplessly by. She compensated by sleeping with everybody in high school except Harry, who was her best friend and Harry's best friend because he asked he not to. As soon as she could, she escaped to Hollywood to be a star, but the only work she's gotten is as a European milkmaid in a cheesy beer commercial with a CGI bear. Harry asks if she wants to come back to his place and, to show he has good intentions, suggests she bring her hostile friend with her.
Harry wakes up the next morning with a girl in his bed. He thinks it's Harmony, but is shocked to find out it's her hostile friend instead. He runs to Harmony's place and apologizes profusely at her door. She's initially pissed, but somewhat mollified as he goes.
Perry and Harry are heading out to a stake out. Gay Perry says that he's gotten a commission from a woman named Allison Ames that he has only spoken to over the phone - to stake a place out and record anything that happens. Harry and Perry drive down a windy dirt road to a woodsy house and hide behind a woodpile with a video camera . Someone comes out of the house in a ski mask, gets in an old beater car and drives off. Harry and Perry follow them by car. They seem to lose him and stop by a pond next to a low ridge to get their bearings. As they look around, the beater car comes shooting airborne over the ridge and lands in the pond. Harry jumps into the water to save the driver as Perry says no one was in the car. Harry persists, and finally Perry dives into the water emerging holding a body. It's a woman in a sundress - she's dead with a broken neck. They drop her on the sand. Harry notices she has no underwear (plot point). Perry says they need to cover this up like they were never there. Harry "helpfully" throws Perry's gun into the water. Perry points out that that was a custom ceramic gun given to him by his mother and it's very traceable. He then smacks Harry in the nose with a briefcase. Two figures in ski masks appear on top of the ridge and shout at them before taking off.
Perry drives Harry back to Harry's hotel. As he drops him off and Harry is walking away, Perry returns with Harry's ringing cell phone that was left in the car. Giving it to him and they both listen as Harry answers. It's the police asking him if he knew of Harmony because her body needs to be identified before being ruled as suicide. Harry is left heartbroken and goes back to his hotel room to drown his sorrows when there's a knock at the door. It's Harmony, somehow alive. Turns out her younger sister has come to town, stolen her credit cards, maxed them out ($2000 to an unspecified party) and then committed suicide; which explains the mistaken call; as the police initially identified the sister as Harmony herself. She's distraught and wants to talk to Harry since she thinks he's a private detective (Flicka told her). She eventually badgers Harry into investigating her sister's murder (she doesn't believe it was suicide) and then faints - it seems Harry agrees so he can spend more time with Harmony in much the way he would get a kick out of her crying on his shoulder when she was upset as a teenager.
She eventually wakes up again and leaves as Harry heads to the loo. The bathroom is long and deep with the toilet on the far end, a bathtub to the left of the toilet and a towel closet to the right of the toilet. Harry is relieving himself standing up when something on the left catches his eye. He turns to look without interrupting the stream and winds up covering the corpse from the car trunk with pee. Someone's stashed it in his bathroom. He crawls into the towel closet and calls Perry. Perry says that it's a setup and somewhere in the room they must have also hidden a gun. Harry quickly finds it under the bed. Down in the hotel lobby Harmony is just leaving as the cops arrive. She overhears that they're headed to Harry's room and makes a quick judgement to misdirect them to a different room. Perry shows up and they bundle up the corpse again. They can't figure out how to get it out of the hotel, so they decide to take it up to the roof and toss it into a dumpster in an alley. They miss and the body bounces off the edge of the dumpster. Harry and Perry rush down to the alley and shove the body into the trunk of the car. Just at that moment the police drive by. Perry grabs Harry and kisses him to make it seem like they're having a liaison. The police crack some jokes and drive off. Harmony shows up just in time to see the kiss. Harry and Perry ditch the body at a random street side location.
The next day Harry and Perry meet and Perry gives Harry two pieces of bad news: 1) He isn't really up for a role in the film. He's being used to demonstrate the producer's seriousness about recasting the role so that Colin Farell will accept less money. 2) He told Harmony that he isn't a PI and she's pissed. Also, it turns out the body in the car was Dexter's daughter (The one who was trying to sue Dexter for the mother's inheritance). Harry heads to the airport to fly home.
While he's waiting for his flight he sees Flicka and tries to chat her up, but she's not very interested. Somehow it comes up that Harmony's stage name is Allison Ames (the name of the woman that hired Perry) and he rushes back to Harmony's place realising the $2000 Harmony's sister spent was to hire Perry to investigate the case he and Harry were on when the car drove into the lake. She doesn't want to hear it and slams the door on him, severing a joint and a half of his left ring finger. She rushes him to the hospital where it's precariously sewn back on and lightly bandaged up. They also drug Harry up really good on pain killers, so he's pretty stoned. In a phone call with Harmony he explains the link between the two cases and leaves a message for Perry who will be at a party Harmony is working that evening. Harry heads over (High as a kite) and they find Perry - who seems disinterested and heads off to an unrelated stakeout of some girl, telling the two to behave until he returns. Harry wanders off to look at a dancer dressed like a deer, but is jumped by two thugs (A white guy, and a black one who calls himself "Mustard" - the same thugs in ski masks who appeared on the ridge after the lake crash) who beat him up and almost pull his finger off again before telling him to get out of town. Harmony and Harry rush off to the hospital to get his finger fixed again when Harmony notices that the two black and white thugs are headed towards Perry's stakeout and insists on going to warn Perry before getting Harry's finger fixed. Harry passes out in the back seat as Harmony parks the car and jumps out to find Perry. She's jumped by one of the thugs, but manages to get the better of him and knock him out - unable to kill "Mustard" the thug but taking his gun.
A girl with purple hair shows up and Perry starts following her. She purposefully leads him under a bridge, the white thug driving up behind him - starting to line up in order to run Perry over. Harmony rushes to save him, dropping her gun and accidentally catching Perry's attention - he spots the approaching car and leaps out of the way. The driver careers toward a hot dog stand destroying tables - just as Gay Perry prepares to kill the white thug as he exits the vehicle, the hot dog vendor shoots the thug down. In the chaos, the girl with purple hair runs around looking for an escape. She finds a car with the door open and the keys still in it. Of course, it's Harmony's car with Harry passed out in the back seat. Harmony returns to where she left the first thug, but he's gone.
Harry wakes up the next day in the back seat of the car in a strange garage in a strange house totally confused (which must mean he got there the entire way without the purple-haired girl seeing him lying asleep in the backseat...) He walks around inside calling out but no one responds. The surviving thug shows up with the girl with purple hair, so Harry hides under a bed. He hears them talking. She's apologizing for the foul up, but says it isn't her fault. The thug agrees and says a number of ominous things about how he's going to set things up so it's never her fault again, and then shoots her dead. Harry holds his fingers to her lips as she mutters before dying. The thug runs off to get something to wrap the body with. So Harry, in a daze, gets out from under the bed. The thug comes back and sees him. The thug starts taunting him until he realizes he's left the gun on the bed. Harry shoots him. Harry's finger has come off, so he puts it in a bowl with ice and calls Perry. While he's talking to him, a dog comes up and grabs the finger. Harry tries to get it back, but the dog swallows it. Harry seems resigned to its loss. He then cleans off the gun, puts the girl's fingerprints on it so the police will think she and the thug killed each other and leaves.
Harmony, Perry and Harry get together to wrap things up, secure in the knowledge that the whole thing was a kidnapping plot gone wrong. Perry jokes that it seems anti-climactic: No one's been tortured yet (foreshadowing). Harry and Harmony head up to Harry's room. Harmony mentions that in an attempt to save her sister's sanity, she told her that their father wasn't really their father. She lied that he was a famous Hollywood film star that had visited town on a "Johnny Gossamer" film shoot. They get wasted at the hotel bar. As Harmony strips in the bedroom to go to sleep, Harry is reminded how the body from the lake wasn't wearing underwear. He offers to sleep on the couch, but they both wind up in the bed about to sleep together when Harmony says she has to admit something. The next shot is Harry throwing her out because she confessed to sleeping with his best friend in high school, the one guy he asked her not to. Harry makes sure her fingers are clear before slamming the door.
Harmony wanders off when something occurs to her. She calls Harry up and asks if the body in the trunk was raped. He replies that it wasn't, the report came back negative. He hangs up. A little later, Perry calls Harry up and says Harmony left a message saying she had it all figured out. Perry wants to know what Harry told her. Harry racks his brain and then mentions the underwear thing. Perry seems to all of a sudden magically figure out what's going on. Perry and Harry go to the local insane asylum, where they meet a large woman patient. They ask her to lift her robe. She does. No underwear. Perry puts it together: Dexter had hidden her daughter away in the looney bin and replaced her with a lookalike so that he could use her to request that the lawsuit dropped. But the daughter's European boyfriend was coming to visit, so he had to kill her to bring the ruse to a close (the boyfriend would see through the double). Harmony's sister must have been the double, which is why they murdered her and made it look like a suicide. Perry and Harry assume that Harmony also went to the asylum and was grabbed, so now they have to find her.
Harry and Perry head out from the asylum where they meet an orderly who holds them at gunpoint and starts marching them back. Perry gets the gun from him and they start trying to interrogate him. Harry, fantastic magician that he is, decides to take the orderly's revolver and pretend to play russian roulette with him to add force to the interrogation. He thinks there's an 8% chance of the one bullet he left in the gun going off. And of course it does. Scratch one orderly. As Perry and Harry hide the body, they're surprised by Dexter and another thug. While they're getting frisked, Perry's phone rings. The thug takes the phone and throws it over to Dexter, but Harry catches it and shuts into the phone that they've been caught by Dexter. The thug retrieves the phone from Harry, listens and tells Dexter that it was just a carpet cleaning service. But it was actually Harmony who managed to pretend to be someone else.They're taken to a hospital to be tortured. We learn the thugs are heading to cremate Dexter's daughter ASAP to remove evidence of gunshot wounds. Thug #3 hooks up electrodes to Harry's balls and proceeds to start the torture. Perry starts taunting him with homophobic slurs. The thug gets angry and starts yelling at Perry, pounding on the electrode button to emphasize his point. Harry's not having a good time. Finally, Perry mimes grabbing at his balls, but it turns out he has a gun hidden there. The thug is killed by bullets flying out of Perry's crotch - he explains homophobes never check the pelvic region.
Harmony calls Perry - she's been at home the whole time. She rushes to the hospital. Dexter and company have loaded the body into a van and are about to leave. Harmony grabs the van and drives off. Three thugs who waited at the van grab a car and chase the van. The back doors of the van are open, so the coffin is in danger of flying out at any time. Harmony crashes the van on an overpass, sending the coffin over the edge. It lands on a sign above the underpass. An arm pops out. Harmony's OK, though. Harry and Perry keep running up and get into a gunfight with one of the thugs. The thug is shot, but not before shooting a bullet through Perry's chest and into Harry. Harry tries to give Perry mouth to mouth, but Perry starts coughing up blood. Meanwhile, Harmony has jumped off the road and into a median, slamming her forehead on the grass and drawing blood. The resulting concussion leaves her pretty dazed, but she manages to call Harry on Perry's cell phone and requests a rescue, then passes out. Harry gets up, taking Perry's gun.
In the process of attempting this rescue, Dexter shows up and tries to run Harry down. He jumps off the overpass and lands on the coffin perched on the freeway sign. He accidentally drops the gun onto the casket and slides off, hanging onto the arm and dangling above the speeding traffic. Dexter rushes to the edge of the bridge to shoot him, Harry jogging the coffin and knocking the gun down - catching it in the nick of time and shooting Dexter. Dexter remarks on what a good shot it is before dying ("Captain fuckin magic"). Some thugs are speeding towards unconscious Harmony to finish her off, but Harry manages to shoot the driver while dangling from the coffin, dropping onto the roof of the car as it passes under. Managing to kill the last two thugs with some showy moves, Harry staggers over to Harmony, and pulls out a Jonny Gossamer book from his breast pocket - complimenting it on stopping the bullet. Harmony points out that it didn't. The hole goes all the way through - thus Harry passes out.
Harry wakes up at the hospital. Harmony is in the room with him. Perry rolls in on a wheelchair. The narrator comments about how much he hates studio enforced happy endings. To slam the point home, everybody who died in the movie walks in (purple-haired girl and thugs included), smiling and waving..... followed by Elvis and Abraham Lincoln. They all disappear, though (except Perry, Harry and Harmony). Perry explains that through his police contacts, he has found that Harmony's sister came to town to find her father, whom she thought was Dexter. She started following him around and what she found eventually saw was Dexter having sex with his "daughter" (which was actually the double and also the one wearing the pink wig). Thinking it was incest, she hired Perry to film it (using Harmony's credit cards) and then killed herself since to her both her real father and pretend father were abusive.
Harmony, Harry and Perry head back to Indiana for Harmony's sister's funeral. Perry confronts Harmony's father, who's on oxygen and bedridden and slaps him repeatedly. Her father taunts Perry for taking advantage of someone who's defenseless and Perry smiles. He's made his point.
The last shot is a year later. Harry, much better dressed, is making a video recording of himself telling the whole story. Perry, who employs him now, walks up, encourages the audience to stay through the credits, rips on the key grip a little and shuts the camera off.