
271 P.3d 739 (2012)
293 Kan. 1051
STATE of Kansas, Appellee,
v.
Randall A. MURRAY, Appellant.
No. 103,773.
Supreme Court of Kansas.
March 2, 2012.
*740 Michael J. Bartee, of Michael J. Bartee, P.A., of Olathe, was on the brief for appellant.
Jerome A. Gorman, district attorney, and Derek Schmidt, attorney general, was with him on the brief for appellee.
The opinion of the court was delivered by
BEIER, J.
Defendant Randall Murray appeals the denial of his motion to correct an illegal sentence for his 28-year-old convictions of aggravated robbery and felony murder. He argues that he did not receive a required competency hearing and thus the district court lacked jurisdiction to try and sentence him. We reverse the district court's decision summarily denying Murray's motion and remand for an evidentiary hearing to determine whether Murray did or did not receive the competency hearing.

FACTUAL AND PROCEDURAL BACKGROUND
Before Murray's jury trial, defense counsel filed a motion to determine Murray's competency under K.S.A. 22-3302. The pertinent *741 passage in the statute's subsection (1) was exactly the same then as it is today:
"At any time after the defendant has been charged with a crime and before pronouncement of sentence, the defendant, the defendant's counsel or the prosecuting attorney may request a determination of the defendant's competency to stand trial. If, upon the request of either party or upon the judge's own knowledge and observation, the judge before whom the case is pending finds that there is reason to believe that the defendant is incompetent to stand trial the proceedings shall be suspended and a hearing conducted to determine the competency of the defendant."
The record before us, which has been reconstructed because of the age of this criminal case, reflects that the district court found good cause for Murray to undergo a competency evaluation the same day that his motion for evaluation was filed.
The record is silent, however, as to whether a post-evaluation competency hearing was ever held. The docket sheet does not reflect the occurrence of such a hearing or the filing of any resulting order. The journal entry of judgment mentions several of the steps in Murray's prosecution, but it does not mention others. For example, it references the complaint, the preliminary hearing, Murray's not guilty plea, the jury trial, and the sentencing; it does not reference Murray's pretrial motion to dismiss and motion to sever his trial from that of his codefendant.
The record does show that, between trial and sentencing, Murray's lawyer filed a second motion questioning Murray's mental state, this time under K.S.A. 22-3429, which provides for mental examinations of defendants as part of the presentence investigation report. It appears from other docket entries that this motion was denied. The record also reflects that Murray's counsel filed a motion for new trial and, eventually, a motion for modification of sentence, neither of which challenged the court's failure to hold a competency hearing and neither of which was successful.
We can also determine that, after an unsuccessful direct appeal, see State v. Murray, No. 55,982, ___ Kan. ___, 679 P.2d 1185, unpublished opinion filed April 27, 1984, Murray filed a series of similarly unsuccessful K.S.A. 60-1507 motions.
Murray's first K.S.A. 60-1507 motion, filed in the mid 1980s, raised an ineffective assistance of counsel claim. It was ultimately rejected by Murray v. State, No. 59,250, unpublished opinion filed September 17, 1987.
Murray's second K.S.A. 60-1507 motion, filed in 2003, challenged Murray's sentences as illegal but only because of his inability to meet with the parole board. His motion was eventually rejected as an improper vehicle for that complaint. Murray v. State, No. 91,724, 2005 WL 283604 (Kan.App.) (unpublished opinion), rev. denied 279 Kan. 1007 (2005).
Murray's third K.S.A. 60-1507 motion, filed in 2005, finally addressed Murray's contention that he had never received a competency hearing before trial, but it did so only as a feature of his renewed ineffective assistance of counsel claim. Murray complained that his trial counsel's failure to pursue the motion to determine competency contributed to constitutionally deficient representation. The Court of Appeals ruled that Murray should have raised this argument in support of ineffective assistance earlier. Murray v. State, No. 96,995, 2007 WL 4577906, at *1 (Kan.App.2007) (unpublished opinion), rev. denied 286 Kan. 1179 (2008).
Murray then filed a federal habeas action under 28 U.S.C. § 2254, arguing for the first time that the state district court's failure to provide him a competency hearing deprived it of subject matter jurisdiction. The State responded by arguing that Murray had failed to exhaust his remedies in state court on this issue. The federal district court agreed, denying Murray relief. Murray v. Goddard, No. 08-3202-SAC, 2009 WL 395195, at *4 (D.Kan.2009) (unpublished opinion).
In 2009, Murray filed the motion to correct illegal sentence that underlies this appeal. He claimed that he first discovered his trial counsel's motion to determine his competency after he filed his second K.S.A. 60-1507 motion. He further asserted that the pretrial court order to determine his competency *742 was ignored and that he was therefore convicted and sentenced by a court lacking jurisdiction.
The district court summarily dismissed Murray's motion to correct illegal sentence, believing the issue had been addressed and rejected by the district court and the Court of Appeals in response to Murray's third K.S.A. 60-1507 motion.

DISCUSSION
An illegal sentence includes one imposed by a court without jurisdiction. Whether a sentence is illegal is a question of law over which this court has unlimited review. State v. Davis, 281 Kan. 169, 174, 130 P.3d 69 (2006).
Once an order to determine competency is issued, a criminal prosecution must be suspended until competency is determined. K.S.A. 22-3302(1); Davis, 281 Kan. at 177, 130 P.3d 69. Failure to suspend prosecution until it is decided that the defendant is competent to stand trial deprives the district court of jurisdiction for trial and sentencing. Davis, 281 Kan. at 180, 130 P.3d 69.
On this appeal, the State makes two arguments. First, it takes the position that Murray waived any right to challenge jurisdiction by waiting too long to pursue it. Second, in contrast to the position it took in Murray's federal case, it argues that the issue of whether the district court had jurisdiction to try and sentence Murray was disposed of by Murray's third K.S.A. 60-1507 action.
The State's first argument lacks merit. Subject matter jurisdiction is subject to challenge by the parties or the court at any time. If subject matter is lacking, any judgment is void. Davis, 281 Kan. at 175, 130 P.3d 69 (quoting State v. Minor, 197 Kan. 296, 300, 416 P.2d 724 [1966]).
The State's second argument also lacks merit. Murray did not challenge the jurisdiction of the district court to try and sentence him on his third motion under K.S.A. 60-1507; he challenged only the effectiveness of his counsel. Although the absence of a competency hearing provided the factual backdrop for both claims, the claims themselves are legally distinct. The federal court was correct to deny relief on the basis of Murray's failure to exhaust his remedies in state court. He needed to pursue the motion underlying this appeal through our state court system. The district court erred in rejecting the motion to correct illegal sentence on the basis that its merits had already been addressed in the third K.S.A. 60-1507 proceeding.
That being said, we cannot grant Murray relief at this level; we must remand. The reconstructed record does not settle the question as to whether the district court had jurisdiction. Cf. State v. Irving, 216 Kan. 588, 589, 533 P.2d 1225 (1975) (court will not presume waiver of jury trial from silent record); State v. Peckham, 255 Kan. 310, 314-18, 875 P.2d 257 (1994) (sentence vacated, remanded when incomplete record did not reflect whether State provided sufficient notice of intent to seek hard 40), disapproved of on other grounds by State v. Marsh, 278 Kan. 520, 532, 102 P.3d 445 (2004).
Every defendant who moves to correct an illegal sentence is not entitled to an evidentiary hearing, see State v. Hoge, 283 Kan. 219, 223, 150 P.3d 905 (2007), but Murray must have one to determine whether his factual assertion that he never received a competency hearing is accurate. Significantly, the State has not argued otherwise so far. On remand, in order to effectively contest Murray's assertion (and presumably his willingness to take the stand and swear that his assertion is the truth), the State must come forward with evidence to fill in the gaps in the reconstructed record to show that a competency hearing occurred. If the district court determines that Murray did not, in fact, receive a competency hearing under K.S.A. 22-3302(1), then the statute and our holding in Davis will compel it to grant relief.
Reversed and remanded to the district court.
