"Those who were standing near Paul said, 'You dare to insult God's high priest?' Paul replied, 'Brothers, I did not realize that he was the high priest; for it is written: "Do not speak evil about the ruler of your people."'" NIV translation
The command that Paul quoted was given to Moses, in Exodus 22:28, and, even though Paul was not under the Law, he did his best to keep the Law as a witness to others. Paul realized and was a great example of the fact that our obedience to God does not depend on the actions of others. He apologized for breaking this law and explained that it happened because of his ignorance of the identity of the high priest.
"Then Paul, knowing that some of them were Sadducees and the others Pharisees, called out in the Sanhedrin, 'My brothers, I am a Pharisee, the son of a Pharisee. I stand on trial because of my hope in the resurrection of the dead.'" NIV translation
Paul understood the people that he was on trial before because he was trained and raised to be a Jewish religious leader. He gets to the heart of the matter which is the resurrection of Jesus Christ.
"When he said this, a dispute broke out between the Pharisees and the Sadducees, and the assembly was divided. (The Sadducees say that there is no resurrection, and that there are neither angels nor spirits, but the Pharisees acknowledge them all.)" NIV translation
The Sadducees believed only in the physical body and the here and now while the Pharisees believed in resurrection and the spirits. After Paul spoke, they started arguing with each other about these things. There are those that say that Paul did this so that he could get away from them but that is not true as we know that Paul knew he was going to be kept and sent to Rome for trial. Even in the face of this trial, Paul was simply stating the facts about Jesus and the resurrection and it was not some clever plan that he dreamed up to escape what he knew God was calling him to do.
"There was a great uproar, and some of the teachers of the Law who were Pharisees stood up and argued vigorously. 'We find nothing wrong with this man,' they said. 'What if a spirit or an angel has spoken to him?'" NIV translation
The Pharisees thought that it was possible that a spirit or angel had given the message to Paul and so defended him. The Sadducees (who did not believe in spirits and angels) are like many Christians today who say that God doesn't talk to His people. We were given the Holy Spirit which is our Counselor and the way that God speaks to our hearts every day.