Robert Rodriguez had touched down in Austin. It was less a homecoming and more a brief stop on the crowded publicity itinerary for Alita: Battle Angel. He'd just wrapped a recording of Overheard With Evan Smith for PBS and was in the green room (a windowless space off a service corridor on the UT-Austin campus) cramming in a few hometown interviews before heading to the airport again. He reeled off the list of destinations: "Korea, London, Paris, Berlin, I'm going to Japan, Beijing, and then I'm done. Oh, and New Zealand."

That insane travel schedule almost seems like he is making up for an act of cinematic audacity: convincing 20th Century Fox to let him shoot Alita – not just his biggest film, but the biggest film ever made in Austin – on his home turf. He beamed. "Did you see the end credit, where it says how many jobs were created? That was pretty awesome, honestly."

The making of Alita is a series of impossibilities. You don't get to direct a movie of this scale in Texas. You don't get to direct a script originally written by James Cameron. And you don't get to make a film that's been floating around for 15 years, eluding all efforts to make it. But this weekend, Rodriguez's retelling of the story of Alita (Rosa Salazar), a cyborg in a distant dystopia, pulls off the impossible.

The first chapters of Yukito Kishiro's Gunnm (translation: Gun Dream) debuted in the anthology magazine Business Jump in 1990 and were translated into English by Viz Media in 1995. Five years later, Guillermo del Toro handed a copy of the manga – now titled Battle Angel Alita – to Cameron, who began a long struggle to make his own adaptation. Cameron's 2000 TV series, Dark Angel, was often seen as a way to scratch that same narrative itch until he finally procured the rights and announced Alita in 2003. Then Avatar happened, and Cameron's dream adaptation went on the back burner.

Rodriguez immediately knew why Cameron would be excited by the story. "I saw the graphic of her and went, 'OK, cyborg, sci-fi, strong female hero. I can see why [he] would be drawn to that.'" After that, he steered completely clear of the project, even refusing to read the manga "so that I could see his movie fresh, thinking, 'That movie will be out in a few years.'" Eventually, he read Cameron's script, "and I was shocked that it is more like his other movies. It's very universal, it's very relatable, and it doesn't feel like this cold, distant, 600-years-in-the-future [story]. It had a warm, beating heart."

That script fell into his hands almost by accident: Back in 2005, he and Cameron were catching up over lunch one day, and Cameron started showing designs for the upcoming Avatar sequels. "I was just like, 'Wow. That's going to take a long time. When are you ever going to make Battle Angel?' And he said, 'I don't think I'll ever have a chance to make it, but do you want to see what I was working on?' 'Yeah, show me!' So he showed me a script, showed me an art reel that had production art put together with narration, and I saw that image of the manga-eyed girl with the porcelain arm."

Impressed as he was, Rodriguez never thought this would become his next big film. "Nobody gets a project like this offered to them," he said. Cameron is much like another close cinematic friend of Rodriguez, Quentin Tarantino: "They don't write that script for someone else to direct. They go to all that trouble writing, it's for them to direct. ... If something happened and they couldn't make it, they'd rather put it in a drawer so they could live with the version that's in their head than give it to another filmmaker and, what? Have it float around and taint the version that they worked on? No, it's not worth it."

Rodriguez quickly realized that Cameron's script wasn't some rough first draft. "A lot of times you read a script and you're like, 'That's not gonna work. This guy's obviously never directed anything before, and we're going to have to make this shootable.' Not with Jim's script. It was like he was watching the movie that was in his head and writing down what he saw. You could see it so clearly." One problem: it was a behemoth, a monolithic 186 pages that probably would have got longer in production. Rodriguez recalled telling Cameron, "It's too long, but I think I can cut it down for you, free of charge. And if you like it and you want to give it to another director, that's fine."

He wasn't nervous about making changes to his friend's script. When adapting someone else's work, he said, "They don't mind the license that you take. They're kind of curious." In fact, rather than the original artist being defensive, "people are sometimes more precious with someone's work than the person who created it."

He returned with a brisk 120 pages, and then he waited for the response. What he got was Cameron and producer Jon Landau telling him that the film – that Holy Grail project – was his.

What they didn't tell him at the time was that when the revisions landed on Landau's desk, the producer was convinced it would be a disaster. How could Rodriguez strip over a third of the script and not take all the heart and soul out with it? According to Rodriguez, Landau told him, "I played a game with myself, Robert. Every time I turned a page, I'd think, 'Oh, is he going to cut my favorite scene? Oh, it's still there. Well, is he going to cut my next favorite scene? Oh, that one's still there.' I managed to get from beginning to end, not knowing how you were going to sweat 60 pages out of it."

"I told him," said Rodriguez, "'Knowing you, I kept the characters and kept the story, and I cut the extra spectacle action and combined a few characters – the things I thought would not be important to you.'"

So Landau and Cameron were on board, but now Rodriguez had the toughest sale: getting the studio to agree to let him shoot in Austin. In the modern film industry, incentives drive location selection, and with the production needing to squeeze every last cent out of the budget, it was coming down to Austin or the seemingly cheaper option of Budapest. So Rodriguez pulled out his secret weapon. "I cooked them an awesome meal."

Rodriguez's main claim to fame is filmmaking, but he's also a notoriously passionate chef, even slipping episodes of his famous "10-Minute Cooking School" onto the Blu-ray extras for his films. But this wasn't just about buttering up the execs with some homemade puerco pibil; after dinner, he told them, "Here's the analogy: If you want a good meal, you don't take a chef out of his kitchen. If you've ever cooked in someone else's kitchen, it takes 10 times longer. You're like, 'Where's the spatula? Where's the pan?' You're lost. If you're in someone else's kitchen, you can't do anything. And they got that."

Now Rodriguez was officially "the dog that caught the car." So he went back to his guerrilla filmmaking roots (or as close to them as he could get on a movie with a nine-figure budget that you know will live and die by having the most photo-realistically motion-captured lead character imaginable).

His script rewrite had been built with two budget constraints in mind. Firstly, that without Cameron's name attached as the director, the budget was going to have to drop. The second was technical: Cameron wanted to make a photo-realistic CG character in 2005, which seemed somewhere between ambitious and madness. This meant that whatever Rodriguez wrote, whatever the budget, there was no sparing any expense on Alita herself. "She's the lead character," he said. To make her look as good as possible in every frame, "I had to have a two hour movie."

But Rodriguez wasn't simply looking to make a bigger-budget Robert Rodriguez movie. He knew that Cameron's creative DNA was what had taken the story from a $10 manga to a massive studio picture, and this was his opportunity to make a James Cameron movie. While Cameron kept telling him to add "a Robert touch," Rodriguez said, "I wanted to see this movie that I've wanted to see since it was first announced that he was doing it in 2003, and the only way I see that movie is if I help him make it, and I've got to help make it in his style."

This isn't a mentor/trainee or holy man/acolyte relationship. Cameron and Rodriguez have been friends for 25 years, and it was Rodriguez who convinced Cameron to start using Steadicams and editing his own movies. "He couldn't believe I was cutting feature films in my apartment, back in 1994, with an AVID [editing system]." They'd had near-misses while working together twice before – once in 1997, when Rodriguez was to direct and Cameron to produce, and again in 2003, when they planned to co-direct. However, the process of developing Alita made Rodriguez realize their differences as storytellers. Take Cameron's first major studio feature, Aliens: Rodriguez said, "You believe that there's an alien queen. Because Sigourney is so real, the world is so real, the tech is so real." Rodriguez compares that to a famous, fantastical moment from his own film, 1995's Desperado. "A guy picks up a guitar case and fires a missile. I don't think an audience really needs to know how it works. The dream logic of it works. But that doesn't work with Jim. He'd be like, 'How does that work? How did that reload? How did that fire without blowing up in his hand? I don't buy it, I don't believe it. It just pulls me out of the movie.'"

(Not that they're completely different filmmakers; in fact, they have a little more in common than Rodriguez realized. There's a bar brawl in the original Alita manga that turned, in the Cameron draft, into what Rodriguez called "a 12-page, kickass bar fight," and he wanted to do both versions justice. He was nervous, so he went on YouTube "just to see what other people had done. I called Jim all excited and said, 'I looked up top 10 bar fights, and four of the top 10 are ours.'" Not only had he forgotten that he's actually shot several such scenes, but two of his films – Desperado and From Dusk Till Dawn – made the list. "I told Jim, 'I guess this is just what we do, so we have to top ourselves, so I'm adding two days to the schedule.'")

Rodriguez's faith in the audience's ability to suspend disbelief is in part how he managed to adapt Frank Miller's hyper-stylized, hyper-violent comic Sin City from page to screen; and if he'd been adapting Kishiro's manga, it might have been a very different film. But he was working not from the manga, but from Cameron's vision, so he threw out a lot of the tools upon which he has previously relied. "I wanted to make this more real, so I'm not going to use green screen. I'm not going to have this layer of artifice over everything, or 'manga come to life' kind of thing. No stylization whatsoever. I wanted to build real sets with real actors, real locations."

That's where filming in Austin – with a crew he knew on locations he had already scouted and in his home base of Troublemaker Studios – played to his strengths: shooting lean and mean. "We shot this thing in 57 days," he said. "It made their heads spin. I did what I had to, to stay in Austin. Even Jim said this movie would have cost twice as much money if he had directed it. So I made a Jim Cameron movie for half the price."

This wasn't just about saving money, but about the spontaneity of his guerrilla style. "I just shot faster, because I found from my early low-budget days that actors do their best work when they're not spending all day on a one-minute scene – when they can just give a real, vital performance."

Yet his new realistic sets only went so high, and he was building a future that reached to the floating city of Zalem and beyond. Making a set from wood and steel and making it look real is easy; but now he had to create a convincing CG world, and that meant new technical challenges. It's the old "uncanny valley" conundrum: The more fantastical an environment is, the easier it is for audiences to believe it. Cameron was pushing the limits of technological filmmaking when he started making Avatar; however, as Rodriguez said, "No one knows what Pandora looks like, so that can all look fake. But here, everyone knows what tables look like, and chairs, so [Alita] has to be as real as that. Otherwise it's a very bad effect."

This was the ultimate challenge: making Alita feel real. The technology was still evolving, and it would still all depend on having the right actress. Rodriguez said, "The next question after I finished the script was, 'Who the hell are we going to cast?'" There was no obvious first choice, so Cameron and Rodriguez went through a long casting process until lightning struck with Salazar. "She came in, gave an incredible performance, and I was like, 'Who was that masked man?'"

What sold him on Salazar's performance was the sheer, excited energy and joy she brought to the character, meshed with a moral steel. "You could cast someone stoic and it would work because she's this warrior, but the CG would be stilted. What I loved about her was that she was so expressive, so effusive, so full of life and character and emotion, that I thought, 'God, if we can get just 50 percent of this [in the] CG model, then it will be the most alive performance we've ever seen' – but they got it closer to 99.9 percent. Every nuance of what she did came through to where I can't even tell the difference between her and the character anymore." Plus, with the art of motion capture now so refined and only getting better, he said, "[S]he can play the part until she's 80 if she wants. That character never has to age."

Yet being able to trust the tech that would make her more metal than flesh was a leap of faith when Rodriguez started filming. When Cameron shot Avatar, his team was designing new software and inventing new technologies while they were filming, with no idea whether it would work or not. Now Rodriguez was in the same situation – hoping that the science of filmmaking would catch up with Cameron's decade-old, photo-realistic dream. He said, "We didn't know how good we [were] going to get it to look. You're not going to know until you're done. So when I'm shooting that shot of her arm, and she has her arm out in a sock, I'm going, 'I hope we figure this out.'"

That's why he built an escape hatch into the script, just in case, when Alita asks another character, "Is it OK that I'm not completely human?"

"It's a great line for the plot, but it's a safety net at the same time, in case she looked plastic. You're reminded that she's supposed to be a cyborg." But with the onscreen version of Alita finally fulfilling Cameron's vision, he said, "It ends up having a stronger thematic meaning because she looks so real."

Alita: Battle Angel opens this weekend. See review and showtimes.