PASADENA, Md. — Maryland residents have been buying guns in record numbers before a law takes effect Tuesday, with provisions aimed at helping keep guns away from criminals and the mentally ill, strengthening safety training and banning 45 types of assault weapons.

Opponents decry what they call an ineffective law that will only make it harder for law-abiding citizens to exercise Second Amendment rights. They say the state also failed to prepare properly for implementation after Gov. Martin O’Malley, who is considering a run for the White House in 2016, pushed the complicated measure through the General Assembly to build his credentials for a potential Democratic primary race.

On Thursday, opponents of the restrictions sued in federal court in Baltimore, seeking to block the legislation from taking effect. The court scheduled a hearing for Tuesday on their motion for an order that would temporarily block implementation while the court considers whether to permanently bar Maryland from enforcing the law.

When O’Malley signed the legislation in May, he highlighted a provision that will require residents who buy a handgun to be fingerprinted to own a handgun, making Maryland the sixth such state to do so.

“States with similar licensing provisions have substantially lower gun death rates than states that do not. So, if we want better results, we have to make better choices, and this legislation is part of that series of better choices that we are making,” the governor said. The other states are Connecticut, Hawaii, Massachusetts, New Jersey and New York.

But state Sen. Nancy Jacobs, a Republican who opposed the measure, questioned the effectiveness of the law, including the fingerprinting provision. She said she submitted the required digital fingerprints when she made a recent gun purchase and was told they could not be recognized correctly. The senator from Har ford County also said criminals will find other ways to get guns, as they always have.

“They are going to continue to buy them on the street,” Jacobs said. “They are going to continue to break into peoples’ homes and steal them. They will get them.”

The law also will limit gun magazines to 10 bullets and broadens police authority to check gun sales and records.

Frank Loane, owner of Pasadena Pawn and Gun in Pasadena, said the sweeping nature of the law has brought in scores of customers this year, including elderly ones. He noted that a 90-year-old man bought a pistol last week. Loane said it has been his best year for firearm sales in the nearly seven years he has operated his store.

“Everybody’s trying to get in to either get an assault rifle or a handgun that they’ve always wanted, and they know the deadline is coming,” Loane said.