Five precepts and lower realms
Reaching at least the Sotapanna state is the only 100% guarantee of not being born in lower realms ever again.

But if you reach at least the second insight knowledge -Paccaya Pariggaha Nana of the 16 stages of insight towards becoming a Sotappanna, it is said that you will not be born in a lower realm in the immediate next life.

If you are a devout Buddhist who keeps to the five precepts, it is highly unlikely to be born in a lower realm in the next life. But there's no guarantee. It mostly depends on the quality of your precepts. As in how well you keep to them.