
As an eighteen year-old, William McKinley enlisted to serve in the Union Army in July of 1861 and served with distinction. He joined the army as a private and left the war a brevetted major, and he saw action at Antietam and in the Shenandoah Valley. When the war ended in 1865, McKinley returned home to Ohio and decided on a career in law. McKinley studied law in the office of an attorney in Poland, Ohio and the next year he continued his studies by attending Albany Law School in New York. After studying there for less than a year, McKinley returned home and was admitted to the bar in Warren, Ohio, in March 1867. Later that year, he moved to Canton, the county seat of Stark County, and opened up a small office. Shortly thereafter, he formed a partnership with George W. Belden, an experienced lawyer and former judge.
McKinley was a popular and successful lawyer. His earnings were ample enough for him to buy a block of buildings on Main Street in Canton. This provided him with a small but consistent rental income to supplement his legal income. When Rutherford B. Hayes, whom he had served under during the war, was nominated for governor in 1867, McKinley made speeches on his behalf in Stark County. This gave McKinley a taste for politics and in 1869, McKinley ran for the office of prosecuting attorney of Stark County, an office usually held by a Democrat. McKinley bucked the odds and won the election. He only served one term and when McKinley ran for re-election in 1871, he was defeated by 143 votes.
On January 25, 1871, McKinley married Ida Saxton, the daughter of a prominent Canton family. Their first child, Katherine, was born on Christmas Day 1871 and a second daughter, Ida, was born in 1873, but died the same year. Further tragedy entered their lives years later, in 1875, when Katherine died of typhoid fever. The McKinleys had no other children. Ida McKinley developed epilepsy around the same time and William McKinley remained devoted to his wife and tended to her medical and emotional needs for the rest of his life.
With Ida's support, William McKinley continued his successful career in law and politics. In 1876 McKinley undertook a high-profile case defending a group of coal miners who were arrested for rioting after a clash with strikebreakers. Taking the case may have seemed unwise at the time. Prosecuting the case was William Lynch, the man who had defeated McKinley in the 1871 election for prosecuting attorney. One of the mine owners was Mark Hanna, a Cleveland businessman who would later become McKinley's campaign manager and closest friend. It was not money that was behind the decision to defend the miners. McKinley accepted the case pro bono (without fee). McKinley recognized an injustice and was guided by his moral compass.
In March of 1876, coal miners in the Tuscarawas Valley struck for higher pay and better working conditions. Their wages had been cut in recent years. The owners brought in strikebreakers and they clashed with the striking miners. Members of both sides were badly injured. Finally troops were called in to stop the violence. Mark Hanna later said that he was impressed with McKinley's quiet and dignified demeanor and his thoroughness. During the trial, McKinley presented evidence about the miners' poverty, their poor living and working conditions and the economic pressures on them that led to the strike. He conceded that their violence was wrong, but argued that violence could have been averted if the mine owners had been more reasonable. He evoked sympathy for the miners with the jurors, and as a result, only one miner was convicted. The remainder were acquitted.

The case raised McKinley’s profile not only as a lawyer, but also with laborers, who were a crucial part of the Stark County electorate and who at the time usually voted Democratic. Their support would contribute to McKinley's political success for years to come. More importantly, it showed a side of McKinley that placed principle ahead of politics. It was a character asset that would be called for years later when, as President, a "yellow press" led by William Randolph Hearst and others wanted the nation to rush into a war with Spain. While McKinley ultimately did lead the nation through the war, he did so only after calmly weighing the evidence to do so. Even McKinley's fiercest political opponents regarded him as a fundamentally decent human being. Although he was passionate about his beliefs, including imposing protectionist tariff rates, his contemporaries described him as a genial figure, someone who made friends simply by being himself. Civility, character and principle helped William McKinley steer the ship of state with a steady hand through turbulent times.