An appeals court has thrown out a 12-year-old drug conviction for an aspiring citizen who is awaiting deportation because he received inaccurate advice from his lawyer when he pleaded guilty in the case.

The decision by a unanimous panel of the Appellate Division, Second Department, reversed a 2014 ruling by Acting Queens Supreme Court Justice Douglas Wong to deny Elvin Pinto’s 440 motion to vacate his conviction of third-degree attempted criminal sale of a controlled substance.