I'm working on this one now with my 4 year old! It seems she was doing this exact thing at 2, and we were responding as you are. So you know, it doesn't go away. It gets better. It gets worse.
The consistent advice is very good and I agree. Whatever you do, go for it and be consistent.
We've tried many things. The sticker chart and reward system worked very well at two. (And still kind of works now, but isn't powerful enough to overcome the nightmares my girl is having now. We just moved.)
Right now, I am sleeping in the room with my girls in order to keep them (the oldest one, though, not really the two year old) in their beds. This is what the pediatrician recommended. I've laid an airmattress on the floor and keep her coralled in her bed all night. It has NOT been easy. She does much better with my husband. She will argue with me for hours about why she should now be on the airmattress with me and not in her bed. But we have had 4 nights in a row in her bed all night. And she got a "prize" this morning. Once she feels safe in her room, I am to move further away from her. Then into the hall. Etc. I'm still early in this process, but this has been the only way we've been able to keep her in her bed since we moved 6 weeks ago.
Good luck!