In 1966, a wealthy industrialist named Phillip Colbert has moved from Chicago to Sparta, Mississippi, to build a factory there. Late one night, police officer Sam Wood discovers Colbert’s murdered body lying in the street.
Chief Gillespie leads the investigation. A doctor estimates that Colbert had been dead for a few hours. At the train station, Wood finds a black man, Virgil Tibbs, and arrests him. Gillespie accuses Tibbs of the murder, and is embarrassed to learn Tibbs is a police officer from Philadelphia. Gillespie phones Tibbs’s chief, who informs Gillespie that Tibbs is a top homicide detective and recommends that he should assist the investigation. The idea does not appeal to either Gillespie or Tibbs, but for reasons of their own they reluctantly agree. Tibbs examines Colbert’s body and concludes the murder happened earlier than the doctor had estimated, that the killer was right-handed, and that the victim had been killed elsewhere and then moved to where the body was found.
Gillespie arrests another suspect, who protests his innocence. The police are planning to beat him into confessing, but Tibbs reveals he is left-handed and has an alibi backed up by witnesses. Colbert’s widow is frustrated by the ineptitude of the police and impressed by Tibbs. She threatens to halt construction of the factory unless Tibbs leads the investigation, and the town’s leading citizens are forced to go along with her wish. The two policemen begin to respect each other as they are forced to work together.
Tibbs initially suspects plantation owner Endicott, a genteel racist and one of the most powerful individuals in town, who publicly opposed the new factory. When Tibbs interrogates Endicott, Endicott slaps him in the face and Tibbs slaps him back. Endicott sends a gang of thugs after Tibbs. Gillespie rescues Tibbs and tells him to leave town for his safety, but Tibbs is convinced he can solve the case.
Tibbs asks Wood to re-trace his car patrol route on the night of the murder, and Gillespie joins them. Tibbs reveals that Wood has changed the route of his patrol. Gillespie discovers that Wood made a sizable deposit into his bank account the day after the murder. He starts to suspect Wood and arrests him, despite Tibbs’s protests. Purdy, a hostile local, brings his 16-year-old sister Delores to the police station and files charges against Wood for getting her pregnant. Tibbs insists on being present when Delores is questioned. Purdy is offended that a black man was present at his sister’s questioning, and gathers a mob to attack Tibbs. Meanwhile, Tibbs tells Gillespie that the murder was committed at the site of the planned factory, which clears Wood of the murder charge, because he couldn’t have driven both his and Colbert’s cars back into town. Tibbs adds that he knows why Wood changed his route: at night Delores likes to display her naked body to whoever is outside, and Wood, who watches her while on duty, did not want Tibbs to see a white woman in the nude.
Tibbs visits a backstreet abortionist, who under pressure reveals that she is about to perform an abortion on Delores. Delores arrives, sees Tibbs, and runs away. Tibbs follows her and comes face to face with her armed boyfriend, Ralph, a cook from a local roadside diner. At that moment Purdy’s mob arrives on the scene and holds Tibbs at gunpoint. Tibbs shouts at Purdy to check Delores’ purse, that it contains money Ralph gave her for an abortion, which he got when he robbed and killed Colbert. Purdy grabs the purse and looks inside, and realizes Tibbs is right. Purdy confronts Ralph for getting his sister pregnant, and a startled Ralph shoots Purdy dead. Tibbs grabs Ralph’s gun, and just then Gillespie arrives on the scene. Ralph is arrested and confesses to Colbert’s murder: he had gone to ask Colbert for a job at the new factory, but ended up attacking him and taking his money. “That’s all. I didn’t mean to kill him,” are the final words of Ralph’s taped confession.
The final scene shows Tibbs boarding a train bound for Philadelphia, as Gillespie, having carried his suitcase, respectfully bids him farewell.