According to this, the STi beat out the E92 M3 by 7 seconds on Nurburgring. Note though that the early e46 M3 CSL has a time 5 seconds faster than the STi, with the super rare M3 GTS a couple seconds faster than that.
Keep in mind the STi used was a JDM 2.0 with a larger turbo designed for 320 HP. Whitch is chicken scratch in terms of power gains. Any typical STi can see that type of bump through tuning alone. Add a Stage II type of kit (which will cost about what the first service inspection runs on the M3) and a couple cool stickers and you can spank an M3.
Having owned an E46 M3 I will say this though, the car is extremely quick and flickable. Between the SMGII, the suspension setup, and the power delivery, it is really easy to drive quickly. The STi on the other hand requires a slightly lighter touch, you almost have to let the car wander (sometimes) and it feels a bit looser. Once you're used to the bit of understeer and navigating the transmission so you stay in boost , and sort the DCCD, the STi is just as fun to drive, way cheaper to maintain, and for all intents and purposes, on the same performance level.