Stepanek, whose inspirational verse made him a best-selling writer and a prominent voice for muscular dystrophy, died last week of a rare form of muscular dystrophy that had plagued him throughout his 13 years. He was buried next to his three siblings - Jamie, Katie and Stevie - who died of the same disease, all at young ages.
Carter, who corresponded with Stepanek for three years, gave the eulogy.
"I have known kings and queens, presidents and prime ministers," Carter said. "But the most extraordinary person I have ever known in my life was Mattie Stepanek."
Four firefighters gingerly lifted a small wooden coffin covered with the United Nations flag from the back of a fire truck outside St. Catherine Laboure Catholic Church.
On the casket was a bumper sticker: "Be a peacemaker."
Stepanek tried to convey that message in the words and drawings in his best-selling books and through his work as an advocate for the Muscular Dystrophy Association. His five volumes of poetry sold more than a million copies.
Like many authors, Stepanek also communicated with his many readers and well-wishers through his web site, which his family has continued for the time being, adding only the announcement of his death.
Carter and Stepanek met in 2001 when it appeared Stepanek was near death. Carter made a surprise visit to his hospital room as a last wish for the boy.
Stepanek rallied and later sent Carter a series of letters in which he discussed becoming a peacemaker and proposed that he and Carter write a book together called "Just Peace."
Carter said he was impressed with Stepanek's knowledge of international affairs, recalling how the boy was moved to tears by the war in Iraq because he thought world leaders had not tried hard enough for peace.
Also speaking briefly at the funeral was Oprah Winfrey, who featured Stepanek many times on her talk show and at one point asked all viewers who believed in the power of prayer to pray for the boy she considered a special friend.
Many of the 1,300 people who filled the church had met Stepanek through his charity work.
In the church, men with ponytails and beards filled several pews, wearing leather vests with Harley Davidson logos. The motorcycle company and Harley owners groups work with the MDA. Firefighters who had also contributed to the charity filled the funeral procession, marching in dress uniforms.
Some mourners never knew Stepanek but came anyway.
Roseanne Mangarella, a preschool teacher in Philadelphia, was given a copy of one of Stepanek's books and later used it in class.
"My heart was telling me I had to help come celebrate this," she said as she stood in line to enter the church. "This is my way of meeting him."