This is pretty much a battle of wills, and you need to put your foot down if you want to win on it. We did this with my son when he was about 20 months and he sleeps beautifully now. It required about 3 nights with a gate up at his bedroom door and a lot of crying.
Night 1: put him back into bed after 5, then 10, then 15 minutes of crying. Repeat every 15 minutes until he falls asleep. Took us 1:45 the first night. He fell asleep by the gate and I moved him into bed later. Not fun.
Night 2: Put him back after 15 minutes of crying, repeat until he falls asleep. He got up once, I put him back, and he fell asleep in bed. Much much better.
Night 3: He fell asleep in his bed.
You'd use the same approach for getting up in the middle of the night, or at 5:00 AM or whenever. We had the gate up in his room for the first couple months and we'd just ignore him if he woke up too early. After a couple times he'd actually just go back to bed by himself once he figured out that he'd get no response from us. Now the gate is down and he sleeps through until 6:30.