It is not something you can just figure out straight away. There are tricks you can use to guess, which I will go through with you in a minute.
It all comes down to learning your vocabulary, and practicing.
tricks wise - in general, those words ending in "tion" will be feminine words such as "la natation" - swimming, or "l'information". Both Feminine.
Another quick tip, is that for the majority, words ending in "ine" are masculin - eh "le comptine" - the nursery rhyme - or "le magasine" - the magazine.
in order to better memorise the gender of words, compile lists of about 10 words per day, 5 masculin and 5 feminine and look over them 2 or 3 times a day - then test yourself on them all at the end of the week.