will not rev above 4000 rpm

can anyone help me i have got a problem with a 1996 mx5 import that will not rev above 4000 rpm whilst driving but will rev freely when standing still.

Added 22/12/08: Thanks for all your help i managed to sort it out. it turned out to be the air flow meter. thanks again

does it run at 4000 dead & then cut out or does it miss & pop & splutter?

 What have you checked or changed so far?

I assume that this is in any gear?

What engine - 1.6 or 1.8, and I assume it is a manual?

Has the timing belt been replaced recently?  Maybe this thread will provide some ideas: http://forum.miata.net/vb/showthread.php?t=232117