Your stay at UK with your spouse can be guaranteed with a Marriage visa. This visa is initially issued for a period of two years and there are provisions of pursuing a job, reentering and exiting the country a number of times. After completion of this time, you need to submit proof that you and your spouse have spent these two years together and then you can apply for ILR.
To apply for this visa, both you and your spouse need to prove that you are legally married and that you are financially independent. You can also apply for this visa if your spouse has an ancestral visa or student visa or work permit. In case you are unmarried you can also apply for this visa. However, you need to submit proof of your finances and that you can support yourself. You also need to prove that you are in that relationship for two years or more and that intent to be in the relationship permanently.