A mechanic's lien is an old legal mechanism to protect companies that do contract work. It essentially gives a company that works on a specific property an automatic lien on that property if they aren't paid according to the contract. Generally, mechanic's liens are easy to enter and difficult to contest. The laws on mechanic's lien vary by state, but there are some general approaches to fighting a mechanic's lien.
Pay. If the work of the contractor is not at issue, the easiest way to settle a mechanic's lien is just to pay. If there's a dispute as to the amount, take into consideration whether or not it would be cheaper and easier to pay versus fighting the lien by possibly getting a lawyer and going to court.
Enter a default. The holder of a mechanic's lien has to go to court to enforce the lien within a certain proscribed by state law. If the lien holder does not file a suit within that period, they have defaulted on their lien and cannot enforce. If they file a suit subsequently, you can show evidence of the default, or, if they are holding your property, you can file a petition showing the default and requesting the release of your property.
Check their license. Many states require the holder of a mechanic's lien to be licensed (if applicable) in the capacity in which they performed the work that gave rise to the lien. The state's website will have a search function that allows you to search for professional licenses and their status. If the contractor's license was lapsed, or they were not licensed at all, the lien might be released.
Argue the contract. A more complicated way to fight a mechanic's lien is to contest the suit by the lien holder on grounds that their work did not satisfy their obligation under the contract, and therefore you have no obligation to pay. This sort of defense would almost certainly involve professional legal counsel. The terms of contracts vary immensely, so there could be multiple reasons why work under the contract can be considered noncompliant.
Invalidate the contract. Similar to step 3, another fairly complicated legal approach to fight a lawsuit enforcing a mechanic's lien is to argue that problem is not the work of the contractor, but the contract itself. There are several reasons why a contract might be invalid, but it would take a professional attorney to know which, if any, apply to your situation.