The Huntington Beach City Council on Monday opted not to outsource the city attorney's office.

An independent attorney hired as a consultant told the council that if the city attorney were to sue the city for attempting to outsource her office, she would likely prevail, leaving taxpayers buried in legal bills.

Ultimately, the council took the advice and opted to preserve Jennifer McGrath's office.

Neighboring Costa Mesa, which is in the middle of an outsourcing legal battle with one of its employee associations, contracts with outside legal counsel. However, Costa Mesa's general employees are challenging their pink slips in court.

"The council saved the city hundreds of thousands of dollars," Councilwoman Connie Boardman said of Huntington Beach's decision. "Costa Mesa has spent about $800,000 defending its outsourcing decision."

Costa Mesa council members in support of its approach have said the employee union is to blame for the legal fees because it sued to block the layoffs.

The council met to vote on its budget, and although residents anticipated a discussion on the outsourcing during a later agenda item, many were surprised when Mayor Don Hansen, who pushed for outsourcing, asked the city manager for the outsourcing analysis and findings.

"This is inappropriate," shouted former Mayor Debbie Cook, when Hansen began the discussion, saying that his move was a violation of the state's open-meetings law.

"Our charter wasn't written for your benefit; it was written for the benefit of the citizens of this city," Cook said during the public comment portion of the meeting. "The voters want an elected attorney who has the strength of character to tell you what you need to hear. You want an appointed attorney who will tell you what you want to hear."

Although the council's staff presented a balanced $294.7-million budget, excluding any potential savings from outsourcing McGrath's office, Hansen said the discussion was part of identifying savings and passing the budget.

The council voted in July to look into outsourcing McGrath's office after Hansen said it would help define cost-saving measures.

City Manager Fred Wilson said 12 firms offered their services. Best Best & Krieger was picked for offering to represent the city for $1.6 million for the first year, he said.

Wilson had set up a selection committee, comprised of him and the two assistant city managers, to review the offers made and pick one based on the city's legal needs. McGrath had refused to take part in the selection committee, which made the process difficult for the city manager's office, Wilson said.

The $1.6-million offer provides the city with about $150,000 in savings, excluding McGrath, who's elected, and her administrative assistant's salaries, Wilson said. Her office's budget is $2.1 million.

Hansen proposed moving forward without outsourcing McGrath's office, but recommended that the city transfer $150,000 — the amount it would have saved from hiring Best Best & Krieger — from McGrath's budget to the Police Department, which lost two sworn positions in this round of budget cuts.

Boardman objected, saying the $150,000 is not a concrete number and cast a substitute motion that allowed the city to dip into its reserves to save the two police officers' positions. The two positions would cost the city $350,000.

The council ended up voting 4-3 to keep McGrath's office intact and earmark $350,000 from the reserve for two police officers if needed by some time next year. Hansen, Harper and Councilman Devin Dwyer dissented.

McGrath summed up her reaction in one word: "relieved."

mona.shadia@latimes.com

Twitter: @MonaShadia