Is a resistor needed between logical pin and base/gate transistor?
My microcontroler has a 20mA max output current


It might, but I have often seen that figure in the "absolute maxima" section. You do know that that section is NOT what you use to design a working system? (You use that section it to design a surviving system, which is something very few of use have to do.)


"without a resistor, what would happen? "


You will be operating the uC outside its rated specs, so anything can happen. (It is your job to keep the current within a stated maximum. Unless the documentation very specifically says so, the uC doesn't have any current-limiting hardware.) A very realistic scenario is that it will work 100% OK on your workbench, but will fail intermittently and mysteriously in in small percentage of devices in the field, and maybe only at full moon.


I have exaclty same doubt about driving a N-channel MOSFET.


Strictly speaking, you must use a current-limiting resistor. In practice, when using a small FET, don't bother. For a large (high current, high gate capacity) FET the resistor is needed, but not just for limiting the drive current: the switching of the load current will couple capacitively to the gate, and can give an 'kickback current' that does nasty things to your uC. In such a case, better use a dedicated gate driver chip.

And as Icy noted, do check that your FET operates OK with 3.3V on the gate. Yet another reason to use a gate driver chip.