Romney, a millionaire businessman credited with cleaning up the Salt Lake Winter Olympics, was unopposed for the Republican nomination.
Late returns showed O'Brien with 33 percent of the vote, followed by former Clinton Cabinet Labor Secretary Robert Reich at 25 percent, state Senate President Thomas Birmingham at 24 percent, and former state Sen. Warren Tolman at 18 percent.
"We have made history tonight," O'Brien told her cheering supporters at a victory party, and was greeted with loud applause when she said she had a question for them: "Are we going to make history in November?"
O'Brien was the first woman nominated by either party as a gubernatorial candidate in Massachusetts. A win in November would make her the first female elected governor in Massachusetts.
Swift initially had said she wanted to run for the post on her own, but gave in to party pressures and stepped aside to give Romney, fresh off three years as boss of the Salt Lake Winter Olympics, an unchallenged shot at the nomination.
This is Romney's second bid for elective office in Massachusetts. He lost in a close race against U.S. Sen. Edward M. Kennedy in 1994.
Kennedy and Sen. John Kerry joined O'Brien at her victory gathering. Kerry was nominated without opposition to run for another term.
Republicans have held the governor's seat in Massachusetts, a Democrat-dominated state, for the past 12 years.
In the race for lieutenant governor on the Republican ticket, Kerry Healey defeated former state party chairman Jim Rappaport, 64 percent to 36 percent.
"What a great campaign, what a winning campaign," Romney said after Healey claimed victory. "We're dedicated to cleaning up the mess on Beacon Hill. Come join us!"
Healey was Romney's handpicked running mate and also a former chair of the state Republican Party. Rappaport had received the party convention's endorsement earlier this summer but was never embraced by the Romney camp.
Chris Gabrieli, O'Brien's choice to be her running mate, easily won the Democratic primary for lieutenant governor with 47 percent of the vote. Lois Pines was second with 30 percent while John Slattery came in last with 23 percent.
Notable deaths of 2014 [PHOTOS]