TOPEKA, Kan. — Kansas Republican legislators Friday narrowly approved a plan for raising taxes, responding to warnings from top aides to Republican Gov. Sam Brownback that failing to erase a budget deficit risked funding for universities and invited a downgrade of the state’s credit ratings.

Legislators in past years backed the Republican governor by slashing personal income taxes in an effort to stimulate the economy, but those policies contributed to a budget deficit that ballooned this year.

Brownback was forced Thursday to publicly plead with Republican legislators to increase the state’s sales and cigarette taxes to balance the next state budget. His pitch – and his aides’ warnings that he would otherwise have to take drastic action early next week – prompted Republican lawmakers to tinker with a plan that had failed early Thursday in the House by a wide margin. They approved a package of two bills.

“It’s not going to get any better,” said Republican Sen. Steve Fitzgerald, a Leavenworth Republican. “We need to get out of here.”

The two bills together would raise $384 million during the fiscal year that begins July 1. Even with the new revenues, Republicans who drafted the plan said Brownback might have to cut up to $50 million in spending.

One measure raises the state’s sales tax to 6.5 percent from 6.15 percent. The House approved it early Friday, 63-44, and the Senate passed it Friday afternoon, 21-19.

“I congratulate them on coming together in a spirit of cooperation and compromise to do what is right for Kansas,” Brownback said in a statement issued after the vote.

The other measure was approved Sunday by the Senate and includes an increase in the cigarette tax of 50 cents a pack, to $1.29, and a modest increase in taxes for business owners and farmers.

Both measures now go to Brownback, who is expected to sign them.