Former Democratic state Sen. Kyrsten Sinema has been elected to represent a new Phoenix-area congressional district, emerging victorious after a bitterly fought race that featured millions of dollars in attack ads.

Sinema becomes the first openly bisexual member of Congress. Her victory came in a year when three states approved gay marriage, and at least five openly gay Democrats were elected to House seats. A Wisconsin congresswoman also became the first openly gay person elected to the Senate.

Sinema had a narrow lead on election night that made the race too close to call. But she slowly improved that advantage as more ballots were tallied in recent days, and now has a nearly 6,000-vote edge that is too much for Republican Vernon Parker to overcome.

Sinema, 36, was on an airplane to Washington on Monday for freshman orientation and not immediately available to comment on her victory.

During the race, Parker, who took the national stage briefly in September when he gave the GOP weekly address, was criticized by Democrats as a tea party radical who would hurt children by cutting the federal education department.

Republicans countered saying Sinema was too liberal for the newly created district and doesn’t understand stay-at-home moms.

One other congressional race remains undecided in Arizona. Rep. Ron Barber, the hand-picked successor to Gabrielle Giffords, had a lead of a few hundred votes over Republican Martha McSally in the Tucson-area district.

The Sinema victory ensures that Democrats will gain at least one seat in the Arizona congressional delegation.

Republicans entered the election with a 5-3 advantage, and the new census added a ninth seat in the state. The delegation is now split 4-4, with the Barber-McSally race still up for grabs.