After Eric Schlosser finished writing Fast Food Nation, reporters kept asking him about Upton Sinclair, and although he had read Sinclair's The Jungle, he did not know about his other works or anything about Sinclair himself. He decided to read most of Sinclair's works, and eventually read the novel Oil!, which he loved. Schlosser, who found the book to be exciting and thought it would make a great film, sought out the Sinclair estate and purchased the film rights. He then thought that he would try to find a director that was as passionate about the book as he was, but Paul Thomas Anderson approached him first.
Anderson had been working on a screenplay about two fighting families. He struggled with the script and soon realized it was not working. Homesick, he purchased a copy of Oil! in London, drawn to its cover illustration of a California oilfield. As he read, Anderson became even more fascinated with the novel, and after contacting Schlosser, adapted the first 150 pages to a screenplay. He began to get a real sense of where his script was going after making many trips to museums dedicated to early oilmen in Bakersfield. Anderson changed the title from Oil! to There Will Be Blood because he felt "there's not enough of the book to feel like it's a proper adaptation". He said of writing the screenplay:
|“||I can remember the way that my desk looked, with so many different scraps of paper and books about the oil industry in the early 20th century, mixed in with pieces of other scripts that I'd written. Everything was coming from so many different sources. But the book was a great stepping-stone. It was so cohesive, the way Upton Sinclair wrote about that period, and his experiences around the oil fields and these independent oilmen. That said, the book is so long that it's only the first couple hundred pages that we ended up using, because there is a certain point where he strays really far from what the original story is. We were really unfaithful to the book. That's not to say I didn't really like the book; I loved it. But there were so many other things floating around. And at a certain point, I became aware of the stuff he was basing it on. What he was writing about was the life of [oil barons] Edward Doheny and Harry Sinclair. So it was like having a really good collaborator, the book.||”|
Anderson, who had previously stated that he would like to work with Daniel Day-Lewis, wrote the screenplay with Day-Lewis in mind and approached the actor when the script was nearly complete. Anderson had heard that Daniel Day-Lewis liked his earlier film Punch-Drunk Love, which gave him the confidence to hand Day-Lewis a copy of the incomplete script. According to Day-Lewis, being asked to do the film was enough to convince him. In an interview with The New York Observer, he elaborated that what drew him to the project was "the understanding that [Anderson] had already entered into that world, [he] wasn't observing it – [he'd] entered into it – and indeed [he'd] populated it with characters who [he] felt had lives of their own".
Anderson has stated that the famous line in the final scene, "I drink your milkshake!", was paraphrased from a quote by former Secretary of the Interior and U.S. Senator from New Mexico, Albert Fall, speaking before a Congressional investigation into the 1920s oil-related Teapot Dome scandal. Anderson said he was fascinated "to see that word [milkshake] among all this official testimony and terminology" to explain the complicated process of oil drainage. In 2013, an independent attempt to locate the statement in Fall's testimony proved unsuccessful—an article published in the Case Western Reserve Law Review suggested that the actual source of the paraphrased quote may instead have been remarks in 2003 by Sen. Pete Domenici of New Mexico during a debate over drilling in the Arctic National Wildlife Refuge. In those remarks, Domenici stated: "The oil is underground, and it is going to be drilled and come up. Here is a giant reservoir underground. Just like a curved straw, you put it underground and maneuver it, and the 'milk shake' is way over there, and your little child wants the milk shake, and they sit over here in their bedroom where they are feeling ill, and they just gobble it up from way down in the kitchen, where you don't even have to move the Mix Master that made the ice cream for them. You don't have to take it up to the bedroom. This describes the actual drilling that is taking place."
According to Joanne Sellar, one of the film's producers, it was a hard film to finance because "the studios didn't think it had the scope of a major picture". It took two years to acquire financing for the film. For the role of Plainview's "son", Anderson looked at people in Los Angeles and New York City, but he realized that they needed someone from Texas who knew how to shoot shotguns and "live in that world". The filmmakers asked around at a school and the principal recommended Dillon Freasier. They did not have him read any scenes and instead talked to him, realizing that he was the perfect person for the role.
To build his character, Day-Lewis started with the voice. Anderson sent him recordings from the late 19th century to 1927 and a copy of the 1948 film The Treasure of the Sierra Madre, including documentaries on its director, John Huston, an important influence on Anderson's film. According to Anderson, he was inspired by the fact that Sierra Madre is "about greed and ambition and paranoia and looking at the worst parts of yourself". While writing the script, he would put the film on before he went to bed at night. To research for the role, Day-Lewis read letters from laborers and studied photographs from the time period. He also read up on oil tycoon Edward Doheny, upon whom Sinclair's book is loosely based.
Principal photography began in June 2006 on a ranch in Marfa, Texas, and took three months. Other location shooting took place in Los Angeles. Anderson tried to shoot the script in sequence with most of the sets on the ranch. Two weeks in, Anderson replaced the actor playing Eli Sunday with Paul Dano, who had originally only been cast in the much smaller role of Paul Sunday, the brother who tipped off Plainview about the oil on the Sunday ranch. A profile of Day-Lewis in The New York Times Magazine suggested that the original actor, Kel O'Neill, had been intimidated by Day-Lewis's intensity and habit of staying in character on and off the set. Both Anderson and Day-Lewis deny this claim, and Day-Lewis stated, "I absolutely don't believe that it was because he was intimidated by me. I happen to believe that—and I hope I'm right."
Anderson first saw Dano in The Ballad of Jack and Rose (in which he co-starred with Day-Lewis) and thought that he would be perfect to play Paul Sunday, a role he originally envisioned to be a 12 or 13-year-old boy. Dano only had four days to prepare for the much larger role of Eli Sunday, but he researched the time period that the film is set in as well as evangelical preachers. The previous two weeks of scenes with Sunday and Plainview had to be re-shot with Dano instead of O'Neill. The interior mansion scenes were filmed at the Greystone Mansion in Beverly Hills, the former real-life home of Edward Doheny Jr., a gift from his father, Edward Doheny. Scenes filmed at Greystone involved the careful renovation of the basement's two lane bowling alley. Anderson said it was "a particular situation, because it was so narrow that there could only be a very limited amount of people at any given time, maybe five or six behind the camera and then the two boys."
Anderson dedicated the film to Robert Altman, who died while Anderson was editing it.
There Will Be Blood was shot using Panavision XL 35 mm cameras outfitted primarily with Panavision C series and high-speed anamorphic lenses.
Day-Lewis broke a rib in a fall during filming.
Anderson had been a fan of Radiohead's music and was impressed with Jonny Greenwood's scoring of the film Bodysong. While writing the script for There Will Be Blood, Anderson heard Greenwood's orchestral piece "Popcorn Superhet Receiver", which prompted him to ask Greenwood to work with him. After initially agreeing to score the film, Greenwood had doubts and thought about backing out, but Anderson's reassurance and enthusiasm for the film convinced him to stick with it. Anderson gave Greenwood a copy of the film and three weeks later he came back with two hours of music recorded at Abbey Road Studios in London. Concerning his approach to composing the soundtrack, Greenwood said to Entertainment Weekly:
|“||I think it was about not necessarily just making period music, which very traditionally you would do. But because they were traditional orchestral sounds, I suppose that's what we hoped was a little unsettling, even though you know all the sounds you're hearing are coming from very old technology. You can just do things with the classical orchestra that do unsettle you, that are sort of slightly wrong, that have some kind of undercurrent that's slightly sinister.||”|
In December 2008, Greenwood's score was nominated for a Grammy in the category of "Best Score Soundtrack Album For Motion Picture, Television Or Other Visual Media" for the 51st Grammy Awards. It features classical music. Brahms' Violin Concerto in D major, Op. 77, 3rd movement, "Vivace ma non troppo" can be heard in the ending titles and during the film Arvo Pärt's Fratres for cello and piano.