Why chandigarh is capital of two states?

because there has been dispute over chandigarh between haryana and punjab.. ..there was a deal of giving 2 cotton districts of punjab to haryana if chandigarh was given to punjab.. but dispute persisted and thus it was made union territory nd serves the capital of both the state.