Cast member Kevin Spacey poses at the premiere for the second season of the television series "House of Cards" at the Directors Guild of America in Los Angeles on Feb. 13. (Mario Anzuoni / Reuters)

The popular Netflix series “House of Cards” will film its third season in Maryland after all, officials announced on Friday, ending a months-long battle between the show’s producers and state leaders over millions of dollars in tax incentives.

The maker of the show, Media Rights Capital, will receive $11.5 million in tax credits in 2014, according to a joint statement released by the company and Gov. Martin O’Malley (D) Friday evening. That’s less money than the show had expected to receive, but enough to continue filming in the state.

Production is expected to begin “over the next several months,” according to the statement, which credited O’Malley with leading the negotiations on behalf of the state.

For the past few years, Maryland has used tax credits to reimburse some expenses for movie and television production companies that choose to film in the state. But the $7.5 million allocated annually to the program is usually not enough to cover the needs of major production companies. As a result, each year, lawmakers are asked to approve an increase.

“House of Cards” filmed its first two seasons in Maryland, generating jobs, spending and a dose of Hollywood buzz— and receiving $26.6 million in tax credits. While most of the filming was in Baltimore and Harford County, the Maryland House of Delegates chamber in Annapolis also was used as a set.

For Season 3, however, Maryland officials at first could only promise the show $4 million.

That prompted letters from a Media Rights Capital senior vice president to O’Malley and House Speaker Michael E. Busch (D-Anne Arundel) in late January, warning that the company would “break down our stage, sets and offices and set up in another state” if additional money did not materialize. Producers delayed the start of filming until June.

The letter ignited weeks of dramatic debate over the film tax credit program, with many lawmakers complaining of extortion. Lawmakers increased the total funding for the tax credit program to $15 million during their annual legislative session, but could not reach an agreement that satisfied “House of Cards” by the end of the session, on April 7.

Instead, O’Malley’s aides huddled with show representatives over the past two weeks to hammer out a final deal.

“Spoiler alert: we’re going to keep the 3,700 jobs and more than 100 million dollars of economic activity and investment that ‘House of Cards’ generates right here in Maryland,” O’Malley said in the statement. “Media Rights Capital has been a great supporter of the people and entertainment community in Maryland, and we couldn’t be happier to continue our partnership.”

Asif Satchu, a chief executive officer at Media Rights Capital, said he was grateful for the “continued advocacy and support” from O’Malley and Maryland General Assembly leaders.

“House of Cards is the gift that keeps on giving,” Satchu said.

John Wagner contributed to this report.