Bynes didn't appear in court, but an affidavit filed on her behalf by attorney Gerald Shargel said she understood the agreement.
"This is an important step in her rehabilitation and she is pleased with the result," he said outside court.
She agreed to attend outpatient therapy twice a week for the next six months, and assuming she complies and stays out of trouble, the case will be sealed and not appear on her record.
The judge allowed an adjournment in contemplation of dismissal, which means Bynes does not have to admit guilt.
Her next court date is June 30, but she is again unlikely to appear in person.
The 27-year-old was charged with criminal pot possession, reckless endangerment and tampering with evidence after investigators say she threw a bong out of the window of her Midtown apartment when offers entered her apartment. Police were called after Bynes allegedly lit a joint in her building's lobby.
In addition to the New York City incident, Bynes was placed on psychiatric hold after she was arrested for allegedly starting a fire in the driveway of a California home.
The woman who lives there said she does not know Bynes and does not have a connection to the actress.
Bynes has made headlines for a string of arrests and odd behavior, including when she wore a bright blue wig to an earlier Manhattan court appearance.
She also has a pending DUI case in Los Angeles after she was arrested and charged with driving with a suspended license. She pleaded no contest and was put on probation for three years.