I recently joined a level 9 gym and I had the lowest CP Pokémon in the gym. The gym did not get taken over by another team, but I got booted out of the gym and it rose to level 10. Why did I get kicked out of the gym if it wasn't taken over?
It is actually not possible for a player on a team to forcibly remove another player of the same team from a gym they occupy. Thus, you were removed by a player on an opposing team.
What likely happened was the gym was taken down a level or two, then brought back up by the time you got back.
The important thing to note is that you were the lowest CP defender in the gym. Thus, if the gym was even taken down a single level, you'd be removed. Raising the gym back up to level 10 wouldn't take too terribly long, especially considering that it was level 9 when you placed your Pokémon in it.
It may be too late now, but in the future, you may want to take note of what players are above you in the gym. That way, if you're kicked out, you can see which users are still in the gym to know how low the gym was knocked down before being brought back up. If none of the players are the same, but the team hasn't appeared to change, then you know the gym was completely taken over and then reclaimed by your team.