In a recent session, an enemy creature tried to charge at our spellcaster. Unknown to him, our Rogue, who had Invisibility cast on him, was in the way. What is the correct way to handle this?
The Charge is stopped
The rules for charging state:
You must have a clear path toward the opponent, and nothing can hinder your movement (such as difficult terrain or obstacles). You must move to the closest space from which you can attack the opponent. If this space is occupied or otherwise blocked, you can’t charge. If any line from your starting space to the ending space passes through a square that blocks movement, slows movement, or contains a creature (even an ally), you can’t charge. Helpless creatures don’t stop a charge.
The invisible rogue will prevent the charge due to this rule. The question is what happens after the enemy charges into the rogue, and RAW doesn't do a great job of covering this.
This movement would be considered illegal and come under the ending in an illegal space rule.
Accidentally Ending Movement in an Illegal Space: Sometimes a character ends its movement while moving through a space where it’s not allowed to stop. When that happens, put your miniature in the last legal position you occupied, or the closest legal position, if there’s a legal position that’s closer.
Sourced from this question on walking into an invisible pc. You should read the answer there, they are quite relevant.
Does the invisibility break?
Only if the rogue takes an attack of opportunity. Which they are entitled to thanks to the creature moving through a square they threaten.
Attempt an overrun
The creature can attempt to overrun the invisible rogue with an appropriate penalty for being unaware of their presence. This should would probably still stop the charge but that's up to you as the DM.
Make an acrobatics check
You could allow the rules on using acrobatics to move through an enemies square. This would not provoke an attack of opportunity if successful but stops movement on a fail. I wouldn't allow this due to invisibility but it is an option.
Let the rogue decide
They are in this position due to clever play, I would employ the rule of cool and let the rogue decide how they would like to play it. Let them make a combat check to trip, or an aoo, or choose to avoid the charge and remain invisible.
RAW, they either stop or take an acrobatics check to move through an opponent's square, if applicable.
First, the Rogue may choose whether or not to take an Attack of Opportunity, as the creature is attempting to move through a threatened square.
You threaten all squares into which you can make a melee attack, even when it is not your turn. Generally, that means everything in all squares adjacent to your space (including diagonally). An enemy that takes certain actions while in a threatened square provokes an attack of opportunity from you.
You can’t move through a square occupied by an opponent unless the opponent is helpless. You can move through a square occupied by a helpless opponent without penalty.
Move Through Threatened Squares
In addition, you can move through a threatened square without provoking an attack of opportunity from an enemy by using Acrobatics. When moving in this way, you move at half speed. You can move at full speed by increasing the DC of the check by 10. [...] If you attempt to move through an enemy’s space and fail the check, you lose the move action and provoke an attack of opportunity.
So the opponent (if applicable) can take an acrobatics check at +15 CMD (+5 for the acrobatic's base check to move through their square, +10 additionally for full-speed) to bypass the AoO and move through the rogue's square. NOTE: if he fails this check, he loses the move action and he's done (paused in front of the Rogue and taking an AoO if so desired.)
NOTE: The opponent cannot use the Overrun maneuver, by pure RAW, because Overrun specifies a target (the target of your charge) that you would attempt to use the combat maneuver on.