Ten years after Star Trek was unceremoniously canceled by NBC, The Motion Picture hit the box office. It was a hit financially, but audiences, critics and even the cast felt the film wasn't the universe at its best. However, the hunt for a Star Trek movie was long and fraught, with the studio giving up and going back to television. Star Trek: The Motion Picture was born from the ashes of a pilot episode for the Phase II series that would've brought the Enterprise back to the small screen.
Source:https://www.cbr.com/star-trek-phase2-pilot-the-motion-picture-origin/