So many of us have been through this! And, trust me, it comes and goes too. My little girl is going to turn 4 soon, and we had the same thing start when she was 2. I remember it all too well since she was such a good sleeper and bedtime routine gal until one day we found ourselves at a loss. As the other moms below said, consistency is key. We also did two other things when she was two (and still use them by the way, although much less necessary now thankfully). First, we sat down together and wrote a set of house rules, just 10, on a piece of paper and put them on the wall in the kitchen. We did this together with her and it has things like: No Yelling or Whining, No hitting, No talking back, Do as Mommy and Daddy Ask, Dinner First- Then Desert, Bedtime means staying in your room, etc. It was funny because she wanted to add so many rules, but we just put up 10 so it was digestible for all. We would just refer to them as needed and breaking the rules, after fair warning (1 warning was all she got), resulted in a loss of a reward....which brings me to the reward. We got a plastic jar and a bunch of plastic butterflies (like the ones for party favors, since she loves butterflies) and we told her that good behavior earns her butterflies and breaking the rules takes away butterflies. We found many opportunities to give her butterflies, such as taking her dishes to the sink after dinner, washing her hands, helping clean up toys, saying please and thank you, etc. etc. It's easy to find stuff. We also told her 10 butterflies and she gets a prize. So the whole thing helps with numbers and counting too. We also explained that at night each time she comes out (unless a dirty diaper), she loses a butterfly. We gave her one warning to stay in her room, and then we would start taking them away. Our little one hated losing butterflies. And, what is important is that we gave her the choice, stay in your room or lose a butterfly. By the way, you cannot force her to go to sleep or be in her bed. Let her have that choice as well. Tell her after lights out/bedtime, she must stay in her room and that it is her choice to look at books or play quietly, but she has to stay in her room. That gives her some control and independence to do as she wishes. She just can't come out. It is mommy and daddy time. Period.
This worked well for my daughter and we broke the coming out of room habit. However her motivations and interest of course changed as she grew. So, while we still have butterflies in a jar, we don't use that in the exact same way anymore. At around 3 years old, we had another bout of getting out of bed/refusing to stay in room. At that time, we adopted something another mom told me about (and about which I was very skeptical to be honest), but I have to say it worked like a charm! Go figure! This approach is to place 3 (or 4 or 5 - you decide) pennies outside of your child's door with her each night at bedtime and tell her that each time she leaves her room (except for potty), you will take away one penny, and however many are left in the morning, she gets to put in her piggy bank! I didn't realize how motivating a few pennies would be. Go figure. She wants to fill that piggy bank (we bought one of the clear plastic ones from The Container Store for $5). That one worked wonders I have to say! She's almost 4 years old now, and bedtimes are fine, but I am sure it's just a matter of ages and stages! ;)
Whatever approach you use, it will take consistency and calmness on your part. She will get that you are not being unfair and your expectations are clear and simple. Stay in the room.
Hope those thoughts helped! Good luck.
By the way - I agree with getting rid of the crib now since she is climbing out. You can either get a toddler bed frame, or just put that mattress on the floor. We ended up buying a full size bed and just placing the mattress and boxspring on the floor. When she's a bigger girl, then she can have a bedroom set. :)