Prior to Star Wars, they had Shell, Exxon, and Esso branded sets. I think sometimes they licensed the Ferrari brand as well.
And yes, Lego has had a Space theme since the late 70s. But it was a general "Space" theme. They would later make Space Police, Blacktron, Magnetron, etc.
But actual Star Wars was 1998. I have some of those sets. It was a big deal to get an actual lightsaber hilt and blade.