In the late 1970s most movie theater owners simply weren’t interested in a movie set in space. The last truly successful science-fiction film had been 1968’s 2001: A Space Odyssey; more recent fare, such as the ecological fable Silent Running (1972), had bombed. So on May 25, 1977 Star Wars opened on just 32 screens nationwide.

It didn’t look like a logical career move for its creator, the director George Lucas, either. After the unexpected smash success of his American Graffiti (1973), which earned him two Oscar nominations and millions of dollars, the then-29-year old director was a hot commodity in Hollywood. For a follow-up he decided to develop an idea he’d been tinkering with for years: a space fantasy, complete with elaborate sets and dazzling special effects. He struck a deal with 20th Century Fox for $150,000 to write and direct the movie that would become Star Wars.

He already had some experience with the sci-fi genre, having filmed the grim, low-budget Orwellian tale THX 1138 (1971). He now aimed to tell a more optimistic and straightforward story of good versus evil, right versus wrong—a story that he felt would particularly appeal to children. But he struggled with the Star Wars script for more than two years, seeking inspiration from sources such as 1950s sci-fi movies, 1930s Flash Gordon serials, and quasi-mystical contemporary sci-fi novels such as Frank Herbert’s Dune. He also studied the work of the writer Joseph Campbell, whose research into various cultures’ archetypical hero mythologies, detailed in his 1949 book The Hero With a Thousand Faces, helped provide a template for the Star Wars plot. “There’s a whole generation growing up without any kind of fairy tales,” Lucas said later. “And kids need fairy tales.”

After constant writing and revising, he eventually had enough material for three movies. But the first one, he knew, had to be a success, and his perfectionism drove him to oversee every aspect of its production. He spent months auditioning relatively unknown actors. Some who were rejected would later become major stars, including Christopher Walken, Nick Nolte, Jodie Foster, and Amy Irving. The role of Luke Skywalker (who was originally going to be named Luke Starkiller) went to the unknown Mark Hamill. Harrison Ford, who had had a bit part in American Graffiti, was cast as Han Solo, and Carrie Fisher, the daughter of the actress Debbie Reynolds and the singer Eddie Fisher, won the part of Leia.

With an initial budget of only $8.5 million, production began in March 1976 in the deserts of Tunisia, in Africa, and one disaster followed another. On the second day of shooting it rained—the first winter rain the area had seen in 50 years. The controls for the robot R2-D2 constantly malfunctioned, and a whole day was spent on a shot of the robot moving only a few feet. Sand damaged camera equipment beyond repair, and windstorms destroyed expensive sets that had been shipped in from England. The production later moved to the sprawling Elstree Studios outside London, and none of the British crew took the project seriously. This was, after all, a movie with robots and a furry “Wookiee.” Technicians inadvertently damaged sets with explosions, one of which caused a stuntman to be hospitalized. The actors, meanwhile, tried to make sense of Lucas’s standoffish directorial style. After one take he admonished them by saying, “Uh. . . let’s do it again, only this time . . . do it better.” Returning to California after the overseas production wrapped, Lucas discovered that his special-effects team, the newly founded Industrial Light & Magic, had completed only 3 of 365 special-effects shots yet had spent more than $1 million of the $2 million special-effects budget. The next day he was hospitalized overnight with chest pains. Suffering from hypertension and exhaustion, he vowed that once he completed Star Wars, he would never direct another film. He and his crew worked around the clock to finish the movie, enduring numerous additional setbacks. The special effects went 35 percent over budget, and the entire film’s budget ballooned to more than $10 million; Mark Hamill suffered a car accident that severely injured his face, making reshoots with him impossible. Many Fox executives were certain the movie would be an unmitigated flop. On May 25, 1977, Star Wars’ release date, Lucas spent the day mixing foreign-language versions in a sound studio in Los Angeles. He called his wife and asked her to meet him at a local hamburger joint for dinner. As they approached the restaurant, the noticed that the streets were clogged with traffic, and crowds of people were filling the sidewalks. He had forgotten that Star Wars was playing at the famous Mann’s Chinese Theatre, across the street from the restaurant. The crowds were there to see his film. Word of mouth quickly spread that the movie was a one-of-a-kind experience, and moviegoers, particularly children, attended it in droves all over the country. Some $3 million in tickets were sold in the first week of release—in only those 32 theaters. By the end of 1977, more than 1 in 20 moviegoers had seen Star Wars several times. By April 1978 it had grossed a staggering $215 million in the United States alone, smashing box-office records. It would go on to rake in six Academy Awards, as well as millions of dollars from product merchandising, including Star Wars calendars, soundtrack albums, and action figures. Five sequels would follow, and the seemingly tireless Lucas would direct three of them. Star Wars not only rejuvenated the moribund science-fiction genre; it also ushered in the era of the summer blockbuster movie—which, for better or worse, transformed the way the movie industry does business. Film companies would increasingly channel millions into big-budget escapist fare and forgo smaller, low-budget films. Lucas’s Industrial Light & Magic would go on to revolutionize visual effects in film. Such spectacle is an integral part of American movies to this day, driving budgets—and box-office grosses—ever higher. For the movie industry, Star Wars was a fairy tale with a very happy ending. —David Rapp has written about history for American Heritage, Technology Review, and Out. He has a degree in film from New York University.