In 1993, when he was the Republican candidate for a seat on the Pennsylvania Supreme Court, Ronald D. Castille said he had it all figured out.

He'd win the seat, serve for 20 years, and by dint of seniority become chief justice for a few months when Justice Ralph J. Cappy (only those few months older) hit retirement age at 70.

Thanks to Cappy's decision yesterday to leave the bench early, Castille's scenario is coming true ahead of schedule.

Cappy, 64, a Democrat from Pittsburgh who has been chief justice since 2003 and a justice since 1990, said he had time to think about the future while recovering from hip-replacement surgery in July.

"I realized that, after nearly three decades on the bench, the time had come for me to pass on the torch," he said.

Castille, a former Philadelphia district attorney known for his toughness, for his confidence, and for his valor in uniform, is now on track to become chief justice at the start of 2008.

A military child who was born in Miami and went to high school in Japan, Castille, 63, never would have been in this position, at least not in Pennsylvania, but for the events of March 16, 1967.

On that day, his 23d birthday, Castille, a lieutenant in the Marine Corps, was hit by near-fatal machine-gun fire during a search-and-destroy mission in a South Vietnamese rice paddy. For his actions, he received a Bronze Star and two Purple Hearts. And doctors had to amputate his right leg at the hip.

Castille spent the next year getting treatment and therapy at the Naval Hospital in South Philadelphia.

After graduating from the University of Virginia Law School - where "everyone had high regard for him," said classmate Carl Tobias, now a law professor at the University of Richmond - Castille returned to Philadelphia, to which he had developed an attachment.

And he never left.

In 1971, Castille joined the District Attorney's Office, then led by Arlen Specter, and became deputy under District Attorney Ed Rendell.

Within the legal community, Castille developed a reputation as a hard-nosed prosecutor. Outside the legal community, he was barely known at all, until 1985.

In that year, he changed his political registration back from Democrat to Republican (where he had started) and ran to replace the departing Rendell, a Democrat.

"What more could you ask for?" Castille said in a 1987 interview in The Inquirer, referring to his qualifications. "I . . . had been described by Philadelphia Magazine as the toughest prosecutor in the system, who eats nails for breakfast."

Helped by a lackluster opponent and public dismay over the May 1985 MOVE confrontation, Castille won easily. He remains the only Republican since 1969 to win a major, contested citywide election.

As district attorney, he increased his office's conviction rate, struggled to cope with drug crime, and chose not to pursue criminal charges against any police officers or other city officials involved in MOVE.

Castille was reelected in 1989, making himself the leading Republican mayoral candidate for 1991. But he wavered about running, entered the race late, and lost a bitter, highly personal primary battle to former Mayor Frank L. Rizzo.

Castille's political popularity survived, and when Specter touted him as a candidate for the state Supreme Court, the Pennsylvania Republican Party made him the nominee. He won a narrow victory and has been on the court ever since.

On the bench, Castille has developed a reputation for being favorably inclined toward prosecutors and willing to speak his mind.

Last year, he took the spotlight by writing a controversial decision about the pay raise that the General Assembly had enacted in July 2005 for legislators, judges and other Pennsylvania officials - and subsequently revoked. His ruling was that the raises for judges could not be undone.

In February, Duquesne University law professor Bruce Ledewitz told a newspaper that the decision made the court "even more corrupt than the legislature." Castille replied with a letter saying he might ask the court's Disciplinary Board to act against Ledewitz for "unfounded and baseless charges of criminal conduct towards this court."

The episode provoked criticism of Castille, who hasn't pursued a complaint.

And it helped reinforce the tough, combative image of the next chief justice of the Pennsylvania Supreme Court.