In her first run for public office, Williams successfully ran for the Pennsylvania House of Representatives from the 149th District. The district covered parts of Montgomery County, including part of Lower Merion, Upper Merion Township, and West Conshohocken. She had decided to run for office after her daughters graduated from high school. In the Democratic primary, Williams defeated Angelo Faragalli, a former Republican who previously ran for the seat in 1994. In the general election, she faced freshman Republican incumbent Colleen Sheehan, whose opposition to abortion and support of school vouchers were seen as too conservative for the district. Williams narrowly defeated Sheehan in November by a margin of 506 votes, becoming the first Democrat to ever represent the district. During her tenure in the House, Williams founded and co-chaired the Children's Caucus, and introduced legislation to give businesses tax credits for donating services or equipment to libraries. She also advocated for increased education spending, and opposed gun control legislation that was written by the National Rifle Association. In 1998, Williams was re-elected to a second term after defeating Mary Wright, a former Lower Merion school board member, by a margin of 58%–42%. During the 2000 presidential primaries, she served as co-chair of U.S. Senator Bill Bradley's campaign in Pennsylvania. In 2000, she defeated Republican Lynne Lechter for a third term, receiving 62% of the vote.
State senator
In 2001, longtime Republican incumbent Richard Tilghman resigned from the Pennsylvania State Senate, where he had represented the 17th District for thirty-two years. The district, covering parts of Montgomery and Delaware Counties, is located in the Philadelphia Main Line. Williams subsequently ran in the special election to fill the remainder of Tilghman's term, facing fellow State Representative Lita Indzel Cohen. During the campaign, Williams ran on her moderate reputation and bipartisan record; she even received several Republican endorsements. She eventually defeated Cohen by a margin of 52%–48%. Williams was sworn in on December 3, 2001. In 2004, she won re-election to a full term after defeating Republican Ted Barry, a Montgomery County assistant district attorney, by 64%–35%. She became known for her work on behalf of children, families, and the environment, and authored a law that allows women to publicly breastfeed their children. During her tenure in the Senate, she served as Senate Democratic Caucus administrator, ranking member of Communications and Technology Committee, co-chair of the Senate Life Sciences and Biotechnology Caucus, and a member of the Governor's Advisory Committee on Minority and Women Business Opportunities. Williams announced that she would not be a candidate for re-election in 2008. In 2010, Politics Magazine named her one of the most influential Democrats in Pennsylvania, noting the value of receiving her endorsement.