The term Jerusalem used in Judges means not the Jerusalem proper in Solomon's time, but the greater area of Jerusalem which was between the border of Judah and Benjamin.
Judges 1:Then the sons of Judah fought against Jerusalem and captured it, and struck it with the edge of the sword, and set the city on fire. ...
21 But the sons of Benjamin did not drive out the Jebusites who lived in Jerusalem; so the Jebusites have lived with the sons of Benjamin in Jerusalem to this day.
Judah could not dislodge the Jebusites, who were living in Jerusalem; to this day the Jebusites live there with the people of Judah.
Does that mean Judah's victory in verse 8 was only temporary? Yes.
Neither Benjamin nor Judah had complete control of Jerusalem in the time of Judges. That came later in 2 Samuel 5 in the time of David:
6 The king and his men marched to Jerusalem to attack the Jebusites, who lived there. The Jebusites said to David, “You will not get in here; even the blind and the lame can ward you off.” They thought, “David cannot get in here.” 7Nevertheless, David captured the fortress of Zion—which is the City of David. ...
This time, control is taken permanently from the Jebusites. David moved in:
9 David then took up residence in the fortress and called it the City of David. He built up the area around it, from the terraces inward. 10And he became more and more powerful, because the Lord God Almighty was with him.