Jeroboam's repair work of the wall in Jerusalem impressed King Solomon so much that he sent him to oversee another job. On his way, Jeroboam met a prophet who told him that after Solomon died, God was going to split the kingdom. Solomon's son would be given only one tribe's portion of land but that tribe would always rule over Jerusalem. Note, Jerusalem is where the temple is. Further note, the temple was necessary for worship. The rest of Israel would be ruled by Jeroboam on the condition that he did what was right in the eyes of the Lord.
Solomon's mood changed. He tried to kill Jeroboam who fled to Egypt. After Solomon died, his son Rehoboam became king.