Digital Pin stuck high when using < 5V

Hi,

I'm using a standalone 328PU + N channel mosFET to turn a motor on and off.

I'm using digital pin D2 to turn the mosfet 'on' and 'off'.

Simple code:

void setup()
{
pinMode(2,OUTPUT);
digitalWrite(2,LOW);
}

void loop()
{
digitalWrite(2,HIGH);
  delay(5000);
digitalWrite(2,LOW);
delay(5000);
}

Scenario 1: When D2 is connected to the mosFET and the supply voltage is less than 5v, the digital pin (D2) get's stuck high and won't toggle on and off.
Scenario 2: When D2 is connected to the mosFET and the supply voltage is at least 5v (And less than 5.5v), pin D2 behaves as expected.
Tests completed under Scenario 1:
a. After D2 gets stuck high I have tried disconnecting pin D2 from the mosfet however pin D2 still remains high. I have to do a power cycle to get it back to normal behaviour.
b. Placing a 5.1kohm resistor from pin D2 to ground, this had no apparent effect.
c. If pin D2 is not connected to the mosFET from powerup it turns high and low as expected until I connect it to the mosFET.

Any idea what's going on here?
Thanks,

Sounds like a bad mosfet or it’s incorrectly wired. Mosfet type?

In general, if the mosfet came from eBay, anything is possible. Semiconductors from China are like the prizes in a box of Cracker Jax, you never know what you’re going to get.