Usually when we talk about divesting liens, we are talking about foreclosure. Divesting can also take place in a judicial sale of real estate aka a free and clear tax sale.
What happens is that a court action is used to clean the title. If proper procedure is followed certain types of liens can be cleaned from the record - or divested.
For instance, if a mortgage lender is in first lien position and they foreclosure, if they gave proper notice to a second mortgage lender, then the second mortgage lien is divested through the foreclosure action.
Some types of lien are not typically divested such as municipal liens or property taxes.