وَعَلِمَ مَا هُمْ عَامِلُونَ قَبْلَ أَنْ يَخْلُقَهُمْ
Allah knew what they would do before He created them.
وَأَمَرَهُمْ بِطَاعَتِهِ وَنَهَاهُمْ عَنْ مَعْصِيَتِهِ
He commanded them to obey Him and forbade them from disobeying Him.
How the passages fit: Allah knows what people will do before they exist, yet commands them to obey and forbids disobedience. Foreknowledge and moral obligation are not contradictory.
Application: Divine knowledge perfectly comprehends events, including human choices. It does not erase accountability. Foreknowledge therefore cannot be invoked as permission to disobey.
Limit of inference: “Allah knows” does not imply “I need not follow the command.”