Most of the Deadpool script fell into the realm of the rights FOX already had with their X-Men license. There was one change thought that had to have Marvel's greenlight before it could be finalized, and all that came down to Negasonic Teenage Warhead.
Seriously, that is the best name of a character ever.
Turns out the team behind Deadpool thought so too, and that was pretty much the reason they picked her for the movie. Which is all well and good, except that the character in the comics is drastically different than the one in the film. Check out the image below for reference.
The character in the books is a telepath who can also see visions of the future. Deadpool needed someone who could beat the living snot out of people so that needed to go. Writer Paul Wernick (via Cinema Blend) illuminated the process of getting her changed.
It was the one thing we needed Marvel’s actual approval on, that they had to reach out for…Tim [Miller, the director] has a relationship with [Marvel President] Kevin Feige and I think he went straight to Kevin because all the lawyers, you know, it gets messy with the lawyers.
Good on Marvel for working with them, as the end result was just what the movie needed. I know they aren't thrilled about not having the rights to the X-Franchise yet, but they also like success and money, so Deadpool is a win on both fronts.